Window out of the screen when maximized using WPF shell integration library Window out of the screen when maximized using WPF shell integration library wpf wpf

Window out of the screen when maximized using WPF shell integration library


Windows crops the edges of the window when it's maximized to obscure what would normally be the resize edges. You can get around this by putting a proxy border between the window and your content and then inflate the thickness when it's maximized.

I modified the example that came with the lib to do this, the same basic change could be made to your sample:

<ControlTemplate TargetType="{x:Type local:SelectableChromeWindow}">  <Border BorderBrush="Green">    <Border.Style>      <Style TargetType="{x:Type Border}">        <Setter Property="BorderThickness" Value="0"/>        <Style.Triggers>          <DataTrigger Binding="{Binding ElementName=ThisWindow, Path=WindowState}" Value="Maximized">            <Setter Property="BorderThickness" Value="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}"/>          </DataTrigger>        </Style.Triggers>      </Style>    </Border.Style>    <Grid [...]/>  </Border></ControlTemplate>

I hope that helps.

For .net 4.5 and above, the SystemParameters are a little different, e.g.:

<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}, Path=WindowState}" Value="Maximized">    <Setter Property="BorderThickness" Value="{Binding Source={x:Static SystemParameters.WindowResizeBorderThickness}}"/></DataTrigger>


this worked for me:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"                xmlns:Views="clr-namespace:BorderLessWpf.Views"><Style TargetType="{x:Type Views:ShellView}" >    <Setter Property="shell:WindowChrome.WindowChrome">        <Setter.Value>            <shell:WindowChrome                ResizeBorderThickness="6"                CaptionHeight="10"                CornerRadius="0"                GlassFrameThickness="1"/>        </Setter.Value>    </Setter>    <Style.Triggers>        <Trigger Property="WindowState" Value="Maximized">            <Setter Property="BorderThickness" Value="6" />        </Trigger>    </Style.Triggers></Style>


In my project, I have CaptionHeight set to 0 and ResizeMode set to CanResizeWithGrip. This is the code I came up with for the proper thickness.

            Thickness maximizeFix = new Thickness(SystemParameters.WindowNonClientFrameThickness.Left +                SystemParameters.WindowResizeBorderThickness.Left,                SystemParameters.WindowNonClientFrameThickness.Top +                SystemParameters.WindowResizeBorderThickness.Top                - SystemParameters.CaptionHeight,                SystemParameters.WindowNonClientFrameThickness.Right +                SystemParameters.WindowResizeBorderThickness.Right,                SystemParameters.WindowNonClientFrameThickness.Bottom +                SystemParameters.WindowResizeBorderThickness.Bottom);

I'm just going to use a border like Joe Castro did and then bind the thickness to a property that I update when the window state changes.

Code seems janky but I haven't found another solution yet.