I have a List Box in my WPF app. Here is the xaml code:
<ListBox Grid.Row="4" Grid.Column="1" Visibility="{Binding lbIsVisible}"> <ListBoxItem> <CheckBox> <TextBlock>CITRUS EXPRESS</TextBlock> </CheckBox> </ListBoxItem> <ListBoxItem> <CheckBox> <TextBlock>APL CALIFORNIA</TextBlock> </CheckBox> </ListBoxItem> <ListBoxItem> <CheckBox> <TextBlock>IS JAPAN</TextBlock> </CheckBox> </ListBoxItem> </ListBox> <CheckBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" x:Name="chkSelectVessel" Checked="chkSelectVessel_Checked"> <TextBlock Text="Select Vessel"></TextBlock> </CheckBox> I'm trying to toggle the visibility of the list box. Here is the C# code.
public partial class ConfigSetting : Window { public string lbIsVisible { get; set; } public ConfigSetting() { InitializeComponent(); DataContext = this; lbIsVisible = "Hidden"; } private void chkSelectVessel_Checked(object sender, RoutedEventArgs e) { this.lbIsVisible = "Visible"; } } But it doesn't seem to work. Can any one point where I'm going wrong?