WPF WindowChrome System Menu Customization

by Avatar Bill Henning (Actipro) - 2 comments
Monday, March 2, 2020 at 5:35pm

Actipro WPF Controls v2020.1 development is in progress, and the new version’s main goals are to modernize our UI control features/themes, and make theme customization much easier.

In the previous post, we saw how the window’s title bar header can be customized.  In today’s post, we’ll look at how the window’s system menu can be customized.

WPF Windows and Win32 System Menus

WPF Windows have always used Win32 to provide their system menus, which are menus displayed when clicking the window’s title bar icon, or when right-clicking on the window title bar.

The Win32 system menu is not rendered by WPF, and therefore never matches the style of a WPF application.  This is especially evident when using dark themes in your app.

An example of a default Win32 system menu in a dark-themed app

This light Win32 menu looks awful compared to dark-themed menus in the same application.

Customizing the System Menu

The latest WindowChrome updates automatically replace the Win32-based system title bar context menu with a custom WPF-based one with similar functionality. There are several benefit to this.

First, the menu will use whatever ContextMenu and MenuItem styles are active in your application. This ensures that the system title bar context menu renders in the same style as other menus in your application.  If you use Actipro Themes with native control theming enabled, the context menu can render in dark theme, etc.

The same system menu, rendered in WPF and with a custom menu item added

Second, since a custom WPF context menu is being created, the menu can be fully-customized via an event prior to being opened. This sample shows how a 'Help' menu item can be injected into the system title bar context menu.

Summary

Using WPF menus for the system menu ensures theme consistency and easily allows for complete customization of the menu’s contents.

Post in the comments below if you have any feedback or questions about WindowChrome system menu customization.

Actipro's WPF Controls

Over 100 UI controls for building beautiful Windows Presentation Foundation desktop apps.

Learn More

Over 100 UI controls for building beautiful Windows Presentation Foundation desktop apps.

Includes editors, docking windows, MDI, property grids, charts, tree controls, ribbons, gauges, themes, and much more.

Learn More Download Free Trial

Comments (2)

Posted 4 years ago by JesperTreetop
Avatar

Will the "double-click to close" function of the system menu icon to the left be maintained?

Posted 4 years ago by Bill Henning (Actipro) - Actipro Software LLC
Avatar

Yes, absolutely.

Add Comment

Please log in to a validated account to post comments.