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

1.3k views Asked by At

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?

1

There are 1 answers

0
JoeTomks On

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