<Grid x:Name="LayoutRoot"><TabControl Name="iii" SelectionChanged="iii_SelectionChanged"><TabItem Header="asdsad"><TabItem.Content><Button Width="60" Height="30" Name="aaa" ContextMenuOpening="aaa_ContextMenuOpening" ContextMenuClosing="aaa_ContextMenuClosing"><Button.ContextMenu><ContextMenu><MenuItem Header="saxas"/></ContextMenu></Button.ContextMenu></Button></TabItem.Content></TabItem><TabItem Header="asdsad"/></TabControl></Grid>
private void aaa_ContextMenuOpening(object sender, ContextMenuEventArgs e) { } private void aaa_ContextMenuClosing(object sender, ContextMenuEventArgs e) { } private void iii_SelectionChanged(object sender, SelectionChangedEventArgs e) { }
When I right click the button in tab 1, it poped the contextmenu, then I click any where but not the tabitem 2, the ContextMenuClosing will be called, but when I click the tabitem2, certainly, the button's contextmenu is closed, but without a call for ContextMenuClosing. I would do something else to make it happen, not as hoped, does anyone know why and do how is better?