I have created a border-less window template so that all window look the same. The template code looks like this:
public abstract class WindowBase : Window
{
static WindowBase()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowBase), new FrameworkPropertyMetadata(typeof(WindowBase)));
}
}
And I have a style which looks like this:
<Style TargetType="{x:Type WindowBase}">
<!--<Setter Property="Topmost" Value="True" />-->
<Setter Property="WindowStyle" Value="None" />
<Setter Property="Background" Value="White"/>
<Setter Property="ResizeMode" Value="CanResizeWithGrip" />
<Setter Property="WindowState" Value="Maximized" />
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border Margin="0" BorderThickness="1">
<Grid>
<Grid Background="White" Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Grid.RowSpan="2"/>
</Grid>
<ContentPresenter />
<ResizeGrip Name="ResizeGroup" VerticalAlignment="Bottom" HorizontalAlignment="Right" KeyboardNavigation.IsTabStop="False"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
<Condition Property="WindowState" Value="Maximized"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="ResizeGroup" Value="Collapsed"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now when the application runs in maximized state, what I have observed is the window exceeds the screen space. Assume I am in 1600 x 900, my maximum work area would be 1600 x 900, but the application takes something like this: 1614 x 914. Also, using WPF Inspector, what I observed is the Top and Left position is in negative. It shows up as '-7' in my case.
I am not sure, where I am going wrong? Can someone help?