0

The problem is the border is too thick for Windows 10.

If you don't see the screenshot below, then here's the text:

  1. This border is too thick at left, right and bottom
  2. Border is also brighter at those edges

How to make a 1px border like Google Chrome (or Windows 10's Explorer) has? Negative 1px doesn't work nice, it makes the border white and it's still thick.

Screenshot of a problem

Framework is .NET Framework 4.6.2.

Code:

<Window
        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:AnotherOffice"
        xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="window" x:Class="AnotherOffice.MainWindow"
        mc:Ignorable="d"
        Title="AnotherOffice Text v0.0.1 - New document" Height="720" Width="1280" Background="{x:Null}" WindowState="Maximized" Margin="0" BorderThickness="8">
    <Window.Style>
        <Style TargetType="{x:Type Window}">
            <Setter Property="WindowChrome.WindowChrome">
                <Setter.Value>
                    <WindowChrome
                        GlassFrameThickness="8,40,8,8"
                        ResizeBorderThickness="2"
                        CornerRadius="0"
                        CaptionHeight="32"
                        UseAeroCaptionButtons="True"
                        />
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Style>
    <local:AnotherOfficeTextBase Margin="0,32,0,0"/>
</Window>

UPD: Tried to use this code:

if (SystemParameters.IsGlassEnabled)
{
    WindowChrome winChrome = new WindowChrome();
    winChrome.CaptionHeight = 32;
    winChrome.CornerRadius = new CornerRadius(0);
    winChrome.GlassFrameThickness = new Thickness(8, 32, 8, 8);
    winChrome.ResizeBorderThickness = new Thickness(1);
    winChrome.UseAeroCaptionButtons = true;
    WindowChrome.SetWindowChrome(this, winChrome);
    InitializeComponent();
} else
{
    MainWindowNoGlass fallback = new MainWindowNoGlass();
    fallback.Show();
    Close();
}

And... no effect.

  • I just use Mah.Apps window style (Even though I don't use their Metro Interface styles anymore). Then I know it's going to be consistent across operating systems and have more control over all the elements. – Joe Sep 23 '16 at 09:10
  • @Joe I'd like to use my own solution because I want to have a TabControl in my window chrome. Any ideas? – ArtyomIsFlash Sep 23 '16 at 09:41
  • Ah, of course. I'd take a look at their BorderlessWindowBehavior code then https://github.com/MahApps/MahApps.Metro/blob/fd47b9ff616febc36c86a6b332578e011f181ce3/MahApps.Metro/Behaviours/BorderlessWindowBehavior.cs. – Joe Sep 23 '16 at 09:59
  • @Joe I guess they are using older .NET Framework version because they're using `Microsoft.Windows.Shell` instead of `System.Windows.Shell` that's why I'm not sure it'll work. Or I don't understand something? – ArtyomIsFlash Sep 23 '16 at 10:11

1 Answers1

1

Here is the easiest solution that I have figured out:

Get rid of all the code relating to border thickness, the window chrome, etc. At the top of the content area in your main window's xaml, paste this:

<WindowChrome.WindowChrome>
    <WindowChrome GlassFrameThickness="0.5,28,0,0.5" NonClientFrameEdges="Right"/>
</WindowChrome.WindowChrome>
<Window.Template>
    <ControlTemplate>
        <ContentPresenter Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Path=Content}"/>
    </ControlTemplate>
</Window.Template>

That will handle everything. You can easily draw content in the Non-Client area, and the window will look normal (enough). If you really need the background to be white as well, you can set the GlassFrameThickness to -1, and draw a 0.5 unit border on the bottom, and left side. Otherwise, you can just draw a large white rectangle.

Alex Fanat
  • 748
  • 10
  • 22