开发者

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

开发者 https://www.devze.com 2023-01-10 11:03 出处:网络
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 sys开发者_如何学JAVAtem menu in the upper-left corner. How would

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 sys开发者_如何学JAVAtem menu in the upper-left corner. How would I do that?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消