Search code examples
c#wpftriggerswindowstate

Checking the value of the window's "WindowState" in a Trigger


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>

Solution

  • 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.