HC’s extension of wpf native Window
.
1 | [ ] |
Attributes
Property | Description | Default Value | Remarks |
---|---|---|---|
CloseButtonBackground | Close button background color | ||
CloseButtonForeground | Close button foreground color | ||
CloseButtonHoverBackground | Close button mouse hover background color | ||
CloseButtonHoverForeground | Close button mouse hover foreground color | ||
OtherButtonBackground | Other Button Background Color | ||
OtherButtonForeground | Foreground color of other buttons | ||
OtherButtonHoverBackground | Other button mouse hover background color | ||
OtherButtonHoverForeground | Other button mouse hover foreground color | ||
NonClientAreaContent | NonClientAreaContent | ||
NonClientAreaBackground | NonClientAreaBackground | NonClientAreaBackground | |
NonClientAreaForeground | Foreground color of non-client area | ||
NonClientAreaHeight | NonClientAreaHeight | ||
ShowNonClientArea | Whether to display non-client area | true | |
ShowTitle | Whether to show the window title | true | |
IsFullScreen | Whether the window is in full screen | false | |
SystemBackdropType | Apply Mica Material for window | false | Only Available in Custom Version |
ShowCloseButton | Show or Hide Close Button | true | Only Available in Custom Version |
ShowMaxButton | Show or Hide Max Button | true | Only Available in Custom Version |
ShowMinButton | Show or Hide Min Button | true | Only Available in Custom Version |
Case
1 | <hc:Window x:Class="HandyControlDemo.Window.CommonWindow" |
Mica Material
Mica is an opaque, dynamic material that incorporates theme and desktop wallpaper to paint the background of long-lived windows such as apps and settings. Mica is specifically designed for app performance as it only samples the desktop wallpaper once to create its visualization.
Mica can only be used on Windows 11 and above
1 | <hc:Window x:Class="HandyControlDemo.MainWindow" |
For synchronization with the Windows theme, set the UsingSystemTheme="True"
property in the app.xaml file
1 | <ResourceDictionary> |
In XAML if you set a background brush for the window and the line is AFTER SystemBackdropType=”Mica”, in Windows 11 the Mica effect is applied to the Window but immediately overridden by the background brush, Mica effect goes away.
Some XAML formatter extensions will sort the properties alphabetically. SystemBackdropType
is then before Background and the “bug” above occurs.
Attached Properties
you can use WindowAttach Attached Property for dragging window or any control.
IsDragElement
1 | <hc:Window WindowAttach:IsDragElement="True" |
SystemBackdropType
you can use SystemBackdropType Attached Property for Activating Mica for any window (System.Window.Window or HandyControl.Controls.Window).
1 | <hc:Window x:Class="HandyControlDemo.MainWindow" |
or
1 | <Window x:Class="HandyControlDemo.MainWindow" |
Shortcut
you should use GlobalShortcut.KeyBindings
1 | <hc:GlobalShortcut.KeyBindings> |
Menu
If you want to use menus in the title bar, you should use NonClientAreaContent property
1 | <hc:Window.NonClientAreaContent> |
NonClientAreaContent
If you want to put objects, you should use it in this way
1 | <hc:Window.NonClientAreaContent> |