I have a StackPanel
which I want to make visible only when SomeTabControl.SelectedItem != null
. How do I do this in WPF binding?
You can do it without a converter by using a style and trigger:
<StackPanel>
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger
Binding="{Binding SelectedItem,ElementName=tabControl1}"
Value="{x:Null}">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
<Style.Triggers>
</Style>
</StackPanel.Style>
</StackPanel>
This example shows the StackPanel by default, but then hides it when the SelectedItem on tabControl1 is null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With