poudigne
poudigne

Reputation: 1766

Display/hide control based on Flags enum value

I have a flags enum containing all Provinces in Canada. In my application I have a list of Checkbox where you can check which province you want to see in the application. I'd like to bind pages from a TabPanel to this enum, so that if Ontario is not Selected i want to hide the tab.

<max:MaxTabControl Grid.Column="1" Margin="2">
        <max:MaxTabItem FieldDescription="Enum:PayrollProvincesType.Federal">
            <ScrollViewer>

            </ScrollViewer>
        </max:MaxTabItem>

        <max:MaxTabItem FieldDescription="Enum:PayrollProvincesType.Quebec">

        </max:MaxTabItem> 
        <!-- more provinces here -->
    </max:MaxTabControl>

Upvotes: 0

Views: 525

Answers (1)

Chris W.
Chris W.

Reputation: 23280

Just grab a Visibility converter and bind to IsChecked of the relevant CheckBox

<CheckBox x:Name="Ontario"/>

<Object Visibility="{Binding Path=IsChecked, 
                             ElementName=Ontario, 
                             Converter={StaticResource VisibilityBooleanConverter}}"/>

Upvotes: 3

Related Questions