C# WPF UI Tutorials: 04 - Custom Window Chrome and Styles
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about custom WPF window chrome, such as maximize offsets, unwanted outlines and DPI-aware screen sizing.
Recommended by 3 people across 3 different months, 2018 to 2021.
What it is
A two-hour tutorial from AngelSix, part of a WPF in C# series, that builds a fully customized application window. It covers custom window chrome, resizing, styled buttons, text boxes and other controls, with source code on GitHub and later Aero docking support.
What people said
Recommends angelsix · 2018-04 · Stack Overflow · on “Very Odd Behavior Accessing Screen Dimensions in C# .NET”
You are not taking into account your monitor DPI scaling. You need to multiply it by that. Here is how I do it [LINK] and here is the long video of me doing it [this video]
Recommends Eric Obermuller · 2018-08 · Stack Overflow · on “My WPF ChromeWindow is slightly off when maximized”
I recommend taking a look at this youtube video. He addresses all the issues with resizing. Pretty in depth series overall. [this video]
Recommends Mohammad Hashem · 2020-05 · Stack Overflow · on “WPF window with custom chrome has unwanted outline on right and bottom”
You can set AllowsTransparency="True" in the window tag, and you can add an OpacityMask. And if you time watch this video [this video] , and that's an example below. <Window ..... xmlns:local="clr-namespace:Your.Project" AllowsTransparency="True"> <FrameworkElement.Resources> <!-- Set the template style of the HolderForm --> <Style TargetType="{x:Type local:YourForm}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Window}"> <!-- Outer border with the drop shadow margin --> <Border Padding="{Binding OuterMarginSize, FallbackValue=0}" BorderBrush="{StaticResource BackgroundDarkBrush}" BorderThickness="{Binding FlatBorderThickness}"> <!-- Main window outline --> <G
Cites liquidair · 2021-06 · Stack Overflow · on “Custom Window Style not showing in design view”
I am attempting to customize the window style in a WPF application in VS2019 (.NET Core 3.1). I'm following along with a video [this video] , currently adding the style directly to the MainWindow.xaml . None of my style shows up in the XAML design view (in the video it does), however, the style shows correctly at runtime. All other styles show up fine. I dug around looking for perhaps a window style I had set somewhere else but I'm not finding anything. At first, I was having an error on the inner <WindowChrome.../> saying "object of type 'Microsoft.VisualStudio.XSurface.Wpf.Window' cannot be converted to type 'System.Windows.Window'" but that issue appears to have resolved itself. I'm not sure i