In WPF, is there a way to check the window's "WindowState" property in a Trigger? I've tried using the value of "0", "Minimized" and "WindowState.Minimized."
EXAMPLE:
<Window.Triggers>
<Trigger Property="WindowState" Value="Minimized">
<Setter Property="ShowInTaskBar" Value="False" />
</Trigger>
</Window.Triggers>
Or if you want a control other than the window to respond to the WindowState property you can use a DataTrigger instead:
<DataTrigger Binding="{Binding WindowState, RelativeSource={RelativeSource AncestorType=Window}}"
Value="Normal">
<Setter Property="Fill" Value="Green"/>
</DataTrigger>
Works like this:
<Window.Style>
<Style TargetType="Window">
<Style.Triggers>
<Trigger Property="WindowState" Value="Minimized">
<Setter Property="ShowInTaskbar" Value="False" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Style>
Edit: You need to place your trigger in the Window.Style
.
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