Default Title bar appearing even with WindowChrome set

142 Views Asked by At

I'm using WindowChrome, and customising the border and the title bar of my application, and it works fine for the most part:

enter image description here

However, for some reason when I run on a certain Virtual Machine (in this case, a German language one using VMware), a white border and title bar (though with no title) appears, and covers my custom title bar:

enter image description here

The odd thing is that I have tried inspecting the application using Snoop, and even on the VM, Snoop does not seem to acknowledge this bar exists. e.g. hovering over the different WPF components, and if I use Snoop's "magnify" function, the title bar appears correctly!

enter image description here

Where could this title bar be coming from and how to get rid of it?

Here is XAML code for a simple application that exhibits the same problem:

<Window x:Class="XamlMessing.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:XamlMessing"
    mc:Ignorable="d"
    Title="MainWindow" Height="298" Width="399" Background="#FF590B0B">

<Window.Resources>

    <WindowChrome x:Key="MyWindowChrome">
        <WindowChrome.CaptionHeight>48</WindowChrome.CaptionHeight>
    </WindowChrome>

    <Style x:Key="MyWindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource {x:Type Window}}">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="ResizeMode" Value="NoResize" />
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="WindowState" Value="Normal" />
        <Setter Property="WindowStyle" Value="SingleBorderWindow" />
        <Setter Property="WindowChrome.WindowChrome" Value="{StaticResource MyWindowChrome}"/>
    </Style>
    
</Window.Resources>

<Window.Style>
    <StaticResource ResourceKey="MyWindowStyle"/>
</Window.Style>

<Grid Margin="0,0,81,107">
    <TextBlock HorizontalAlignment="Left" Margin="125,89,0,0" TextWrapping="Wrap" Text="Hello, World" VerticalAlignment="Top" Height="61" Width="175" FontSize="24" Foreground="#FFDAE463"/>
</Grid>
</Window>
1

There are 1 best solutions below

0
On

OK it seems to be fixed by setting...

<WindowChrome.GlassFrameThickness>0</WindowChrome.GlassFrameThickness>

But I would still be interested to know what was causing it to appear in the first place, since that setting wasn't required on devices other than the VM...