"how to boolean && two visibility converters" Code Answer


you could use a multibinding together with a short, hand made imultivalueconverter.


        <local:multibooleantovisibilityconverter x:key="converter" />
    <checkbox x:name="box1" />
    <checkbox x:name="box2" />
    <textblock text="hidden text">
            <multibinding converter="{staticresource converter}">
                <binding elementname="box1"
                            path="ischecked" />
                <binding elementname="box2"
                            path="ischecked" />

... and the converter ...

class multibooleantovisibilityconverter : imultivalueconverter
    public object convert(object[] values,
                            type targettype,
                            object parameter,
                            system.globalization.cultureinfo culture)
        bool visible = true;
        foreach (object value in values)
            if (value is bool)
                visible = visible && (bool)value;

        if (visible)
            return system.windows.visibility.visible;
            return system.windows.visibility.hidden;

    public object[] convertback(object value,
                                type[] targettypes,
                                object parameter,
                                system.globalization.cultureinfo culture)
        throw new notimplementedexception();
By Quantico on January 2 2022

Answers related to “how to boolean && two visibility converters”

Only authorized users can answer the Search term. Please sign in first, or register a free account.