简体   繁体   中英

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>

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}}"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM