You can use the built-in BooleanToVisibilityConverter . Here's a working sample:
<Window x:Class="WpfApplication16.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:WpfApplication16" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <BooleanToVisibilityConverter x:Key="b2v" /> </Window.Resources> <StackPanel> <CheckBox x:Name="chk" Content="Show There" /> <TabControl> <TabItem Header="Hello" /> <TabItem Header="There" Visibility="{Binding IsChecked,ElementName=chk,Converter={StaticResource b2v}}" /> <TabItem Header="World" /> </TabControl> </StackPanel> </Window>
Matt hamilton
source share