Maximising (expanding) a WPF window

Writing program design in the style of Windows 8 (Flat/Metro).
From the main window MainWindow.xaml-set properties -
WindowStyle="None"
AllowsTransparency="True"

Maximized (maximized) the window takes up the entire screen, i.e. the "task Bar" windows is also not visible. Is it possible to make some kind of indent from the bottom, or somehow "push" one layer back (like in photoshop, for example). Thank you in advance
October 3rd 19 at 01:40
1 answer
October 3rd 19 at 01:42
Solution
You can use Microsoft.Windows.Shell.WindowChrome.
FakeBorder need to ensure that when you maximize a window, the client portion does not exceed the limits of the screen. The source did not remember, somewhere on the msdn forums found.
<controltemplate x:key="DefaultWindowTemplate" targettype="{x:Type Window}">
 <border name="FakeBorder" borderbrush="Green">
<border.style>
 <style targettype="{x:Type Border}">
 <Setter Property="BorderThickness" Value="0"/>
<Style.Triggers>
 <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WindowState}" Value="Maximized">
 <Setter Property="BorderThickness" Value="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}"/>
</DataTrigger>
</Style.Triggers>
</style>
</border.style>
 <border name="WindowBorder" background="{TemplateBinding Background}" borderbrush="{TemplateBinding BorderBrush}" borderthickness="{TemplateBinding BorderThickness}" margin="0">
<grid>
<grid.rowdefinitions>
 <rowdefinition height="{StaticResource grdlenWindowCaptionHeight}">
 <rowdefinition height="*">
</rowdefinition></rowdefinition></grid.rowdefinitions>
 <border name="TitleBorder" background="{TemplateBinding Background}" margin="{TemplateBinding Margin}">
<grid>
<grid.columndefinitions>
 <columndefinition width="*">
 <columndefinition width="Auto">
 <columndefinition width="Auto">
 <columndefinition width="Auto">
 <columndefinition width="5">
</columndefinition></columndefinition></columndefinition></columndefinition></columndefinition></grid.columndefinitions>
 <stackpanel orientation="Horizontal">
 <img margin="6,4,6,4" source="{TemplateBinding Icon}" verticalalignment="Center">
 <textblock verticalalignment="Center" margin="0,0,0,0" text="{TemplateBinding Title}" style="{StaticResource WindowTitleTextBlock}">
</textblock></stackpanel>
 <button name="MinimizeButton" grid.column="1" margin="0" style="{StaticResource ButtonWindowTitle}" command="{Binding Source={x:Static theme:ThemeCommands.Windows}, Path=MinWindow}" commandparameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
 <path data="{StaticResource iconWindowMinimize}" style="{StaticResource PathIcon9}">
</path></button>
 <button name="MaximizeButton" grid.column="2" style="{StaticResource ButtonWindowTitle}" command="{Binding Source={x:Static theme:ThemeCommands.Windows}, Path=MaxWindow}" commandparameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
 <path name="MaximizeIcon" data="{StaticResource iconWindowMaximize}" style="{StaticResource PathIcon9}">
</path></button>
 <button name="CloseButton" grid.column="3" style="{StaticResource ButtonWindowTitle}" command="{Binding Source={x:Static theme:ThemeCommands.Windows}, Path=CloseWindow}" commandparameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
 <path data="{StaticResource iconWindowClose}" style="{StaticResource PathIcon9}">
</path></button>
</grid>
</border>

 <contentpresenter margin="0" grid.row="1" content="{TemplateBinding Content}">
</contentpresenter></grid>
</border>
</border>
<controltemplate.triggers>
 <trigger property="WindowState" value="Maximized">
 <setter targetname="MaximizeIcon" property="Data" value="{StaticResource iconWindowRestore}">
</setter></trigger>
 <trigger property="IsActive" value="False">
 <setter targetname="WindowBorder" property="BorderBrush" value="{StaticResource WindowBorderInactiveBrush}">
</setter></trigger>
 <trigger property="WindowStyle" value="ToolWindow">
 <setter targetname="MinimizeButton" property="Visibility" value="Hidden">
 <setter targetname="MaximizeButton" property="Visibility" value="Hidden">
</setter></setter></trigger>
 <trigger property="WindowStyle" value="ThreeDBorderWindow">
 <setter property="BorderThickness" value="7">
</setter></trigger>
 <trigger property="WindowStyle" value="None">
 <setter targetname="MinimizeButton" property="Visibility" value="Hidden">
 <setter targetname="MaximizeButton" property="Visibility" value="Hidden">
 <setter targetname="CloseButton" property="Visibility" value="Hidden">
</setter></setter></setter></trigger>
</controltemplate.triggers>
</controltemplate>

<style x:key="WindowDefault" targettype="{x:Type Window}">
 <Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
 <Setter Property="Foreground" Value="{StaticResource ControlForegroundBrush}" />
 <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
 <Setter Property="BorderThickness" Value="1" />
 <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
 <Setter Property="FontSize" Value="{StaticResource DefaultFontSize}" />
 <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
 <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
 <Setter Property="SnapsToDevicePixels" Value="True" />
 <Setter Property="OverridesDefaultStyle" Value="true"/>
 <Setter Property="Padding" Value="0"/>
 <Setter Property="shell:WindowChrome.WindowChrome">
<Setter methods.Value>
<shell:WindowChrome
ResizeBorderThickness="6"
 CaptionHeight="{StaticResource WindowCaptionHeight}"
 CornerRadius="0" 
GlassFrameThickness="0,0,0,1"/>
</Setter methods.Value>
</Setter>
 <Setter Property="Template" Value="{DynamicResource DefaultWindowTemplate}"/> 
 </style>
Thank you for the detailed answer - madyson_Wilderman15 commented on October 3rd 19 at 01:45

Find more questions by tags C#WindowsWPF