0
我有datagrid与上下文菜单。它以编程方式初始化:点击后保持打开的上下文菜单
contextMenu = new ContextMenu();
foreach (var col in this.Columns)
{
var checkBox = new MenuItem()
{
Header = col.Header
};
Binding myBinding = new Binding("Visibility");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Converter = new IsCheckedToVisibilityConverter();
checkBox.DataContext = col;
checkBox.SetBinding(MenuItem.IsCheckedProperty, myBinding);
checkBox.Click += checkBox_Click;
checkBox.Checked += checkBox_Checked;
checkBox.Unchecked += checkBox_Unchecked;
contextMenu.Items.Add(checkBox);
}
它很好,但我想保持打开上下文菜单后检查\ uncheck menuitems。有任何想法吗 ?
对不起后,但我怎么能赶上文本菜单关闭事件? – maskalek 2014-09-04 06:47:59
该死的我忘记了contextmenu没有关闭事件。那么也许Collapse事件会起作用,但我不确定。 http://www.vbforums.com/showthread.php?551802-RESOLVED-2008-ContextMenu-Closed-Event – HeadShotSmiley 2014-09-04 09:26:46