Double-click to maximize and restore Right-click to display system menu Drag to top to maximize, drag away to unmaximize.
CustomChromeWindow - Extends Window by adding CaptionButtonMargin, which provides adjusted margins for the caption buttons and window icon when the window is maximized.
However, it doesn't provide much help for the following additional features: Caption buttons (minimize, maximize/restore, close) Caption button hover glow (not addressed in this article) Border shadow (not addressed in this article) Window title abbreviated with ellipsis for smaller window width (not addressed in this article) In attempting to create a fully-functional window with custom.
First the window and its XAML are presented, and after that the underlying code and supporting library are explained.
Xaml" / / rgedDictionaries / ResourceDictionary / sources Grid lumnDefinitions ColumnDefinition Width " " / / lumnDefinitions wDefinitions RowDefinition Height " auto" / RowDefinition Height " " / / wDefinitions - Border CornerRadius " 10,10,5,5" wSpan " 2" BorderThickness " 3" BorderBrush " LightSteelBlue" ckground LinearGradientBrush StartPoint " 0.5,0" EndPoint " 0.5,1" GradientStop Color ".
Part 2 of this article will explain these classes and how to use them in greater detail.
CaptionHeight specifies how much manual of the top of the window is occupied by the title bar and should respond to click-and-drag, double-click to maximize, and right-click for system menu.
The full capabilities of this class and how to customize it require an article unto itself.
WindowChrome shell:WindowChrome ResizeBorderThickness " 6" CaptionHeight " 43" CornerRadius " 25,25,10,10" GlassFrameThickness " 0" / shell:WindowChrome / shell:WindowChrome.
Window4" w xmlns " m/winfx/2006/xaml/presentation" xmlns:x " m/winfx/2006/xaml" xmlns:shell " m/winfx/2006/xaml/presentation/shell" xmlns:ccl " clr-namespace:CustomChromeLibrary;assemblyCustomChromeLibrary" xmlns:local " clr-namespace:CustomChromeSample" Title " Custom Chrome Sample" Height " 350" Width " 525" shell:WindowChrome.
/ TextBlock / Grid / Grid / ccl:CustomChromeWindow CustomChromeLibrary The key to providing complete window functionality in a window with custom chrome is the CustomChromeLibrary.
It is up to us to match the WindowChrome settings to the visual dimensions of our custom chrome window.
Fully Functional Custom Chrome Window The final steps to completing our custom chrome window are: Add the caption buttons using the pre-defined CaptionButtons user control, or individual CaptionButton controls if we want to customize the buttons.
Here's the XAML for the Window declaration as well as the WindowChrome from the Shell Integration Library: Window x:Class " CustomChromeSample.
Window3" xmlns " m/winfx/2006/xaml/presentation" xmlns:x " m/winfx/2006/xaml" xmlns:local " clr-namespace:CustomChromeSample" WindowStyle " None" ResizeMode " NoResize" Title " Window 3 - No Chrome" Height " 350" Width " 525" Restoring Standard Behavior The WPF Shell Integration Library restores the basic functionality.
MinimizeButton MaximizeButton CloseButton CaptionButtons - Combines MinimizeButton, MaximizeButton, and CloseButton into a standard grouping that can be conveniently included in custom chrome windows.
This article shows how to use the.
WPF Shell Integration Library to solve most of these problems, and builds on this foundation by adding caption buttons (minimize, maximize/restore, and close) and a window icon control that displays the system menu on click and closes on double-click.
WindowChrome The WindowChrome class restores the basic window functionality that we lost when we set WindowStyle to "None".
Window5" xmlns " m/winfx/2006/xaml/presentation" xmlns:x " m/winfx/2006/xaml" xmlns:shell " m/winfx/2006/xaml/presentation/shell" xmlns:ccl " clr-namespace:CustomChromeLibrary;assemblyCustomChromeLibrary" xmlns:local " clr-namespace:CustomChromeSample" Title " Custom Chrome Sample" Height " 350" Width " 525" shell:WindowChrome.