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