Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: Add an "Always On Top" menu item to the system menu

Tags:

wpf

systemmenu

I have a monitoring tool where some, but not all, users want it to be displayed always on top.

I would like to add this option to the system menu in the upper-left corner. How would I do that?

like image 528
Jonathan Allen Avatar asked Aug 02 '10 22:08

Jonathan Allen


1 Answers

I would strongly suggest referring to this thread here at stackoverflow:

How can I customize the system menu of a Windows Form?

The above thread utilises unmanaged C++ but they have wrapped it quite well, it should still work adequately in WPF.

Then you would simply ensure that when the custom option was pressed it toggles the topmost property of the application:

bool tpMost = false;

This.Topmost = !tpMost; //Used to switch the bool value
like image 124
JoeTomks Avatar answered Oct 16 '22 16:10

JoeTomks