Get WPF ContextMenu to show on Winforms NotifyIcon

北城以北 提交于 2019-12-11 06:50:06

问题


I am using the Winforms NotifyIcon as there is no WPF Version, I am also using the ContextMenu tutorial here: http://www.wpftutorial.net/ContextMenu.html

And I will be using the mouse placement code found in the answer here: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8cdd4ef1-d31e-42ef-a30e-7b482c0fa163/

My main problem is, the method:

private void OpenContextMenu(FrameworkElement element)
{
    if( element.ContextMenu != null )
    {
       element.ContextMenu.PlacementTarget = element;
       element.ContextMenu.IsOpen = true;
    }
}

How is it used? Can anyone tell me what steps I will need to do just to get this to show up for my NotifyIcon

Thanks


回答1:


CodePlex has a WPF version of NotifyIcon. That might meet your needs better.




回答2:


I found this one out myself, it does the job and very easy to implement.

http://weblogs.asp.net/marianor/archive/2007/10/15/a-wpf-wrapper-around-windows-form-notifyicon.aspx



来源:https://stackoverflow.com/questions/6539672/get-wpf-contextmenu-to-show-on-winforms-notifyicon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!