简体   繁体   English

绑定上下文菜单的IsClosed属性

[英]Bind IsClosed property of context menu

I have project which implements MVVM pattern. 我有一个实现MVVM模式的项目。 I have WPF window which has reusable usercontrol in his xaml. 我有WPF窗口,该窗口在他的xaml中具有可重复使用的usercontrol。 UserControl consist of WPFDataGrid. UserControl由WPFDataGrid组成。 Also DataGrid has ContextMenu. 另外,DataGrid具有ContextMenu。 I want do some staff when context menu is closed. 关闭上下文菜单时,我想做一些工作人员。 But ContextMenu class have not dependency property which give me ability to know is it close or not. 但是ContextMenu类没有依赖项属性,这使我能够知道它是否关闭。 I cannot farword his Close event to the ViewModel because I havent ViewModel object in the level of UserControl. 我无法将他的Close事件发送到ViewModel,因为我在UserControl级别没有ViewModel对象。 I think that I can do this this using attached DependecyProperty and create IsClosed attached property for ContextMenu Class. 我认为我可以使用附加的DependecyProperty做到这一点,并为ContextMenu类创建IsClosed附加属性。

Question: How can do this with attached dependecy property or other approach using MVVM? 问题:如何通过附加的依附属性或使用MVVM的其他方法来做到这一点?

PS Code snippet is desirable PS代码段是可取的

但是它确实有IsOpen :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM