How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?

╄→гoц情女王★ 提交于 2019-12-10 11:45:27

问题


When I use ContextMenu from Silverlight 4 Toolkit I want to get ContextMenu instance's Owner, but it's not available since in ContextMenu class Owner is an internal property. For example, I have a Rectangle put inside a Border. When I right-click a Rectangle (and a context menu appears) I need to change the Rectangle Border's thickness to indicate that the Rectangle is the current element of the parent Grid, for example. So I try to use ContextMenu.Loaded event where I get the ContextMenu (through the sender parameter), but I can't get the Owner of that ContextMenu (i.e. the Rectangle with its Border). And I need that Owner to make its Border thicker. Please help me find the way to do that.


回答1:


The only soultion I found was to set ContextMenu's DataContext to the needed element from code behind. And then to address the element on which the context menu was opened throught that DataContext property.



来源:https://stackoverflow.com/questions/5361075/how-to-get-the-owner-of-the-contextmenu-from-silverlight-4-toolkit

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