Make Control Visible Only if Window Maximized

Nov 14, 2012 at 4:42 PM

I'm trying to collapse a control as long as the parent window is not maximized.

Here is what I have so far (collapsing if ActualHeight < 500) and is working:

<Window x:Class="TestApp.AnalyseWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpfconverter="clr-namespace:WpfConverter;assembly=WpfConverter"
        x:Name="thisControl"
        WindowState="Maximized"
        Height="600" Width="800"
        MinHeight="300" MinWidth="300">
    <DockPanel>
        <Label DockPanel.Dock="Bottom" Content="Only show when maximized">
            <Label.Visibility>
                <Binding>
                    <Binding.ElementName>thisControl</Binding.ElementName>
                    <Binding.Path>ActualHeight</Binding.Path>
                    <Binding.Converter>
                        <wpfconverter:ExpressionConverter>
                            <![CDATA[
                            {0}  < 500 ? "Collapsed" : "Visible"
                        ]]>
                        </wpfconverter:ExpressionConverter>
                    </Binding.Converter>
                </Binding>
            </Label.Visibility>
        </Label>
        <Label Content="Show always" />
    </DockPanel>
</Window>


 

But what I can't get to work is doing something like {0} == "Maximized" ? "Visible" : "Collapsed" on the binding path WindowState.

Can anybody tell me, how to do this on the WindowState of thisControl?