I have a
ContextMenu as part of a
TabControl such as:
<TabControl Name="MyTabControl"> <TabControl.ContextMenu> <ContextMenu Name="MyContextMenu" IsEnabled="False" StaysOpen="True"> <MenuItem Header="Item1"></MenuItem> ... </ContextMenu> </TabControl.ContextMenu> </TabControl>
As you can see, the menu is disabled. It will be enabled later in the program, for now however, it should remain in its disabled state. The problem is, when I right-click the
TabControl and the disabled menu shows, it simply stays where it was first opened, no other right-click will move it, nor will a left-click somewhere make it disappear.
The only way to get rid of it, would be either by enabling it and then right/left-clicking, or by using
MyContextMenu.Visibility = Visibility.Collapsed/Hidden;
I tried setting the
False. Then the menu will open once in its disabled state. After left-clicking disappear and then not appear again even if it gets enabled.
The only way around it could be changing the
StaysOpen-property along with the
IsEnabled-property, but it is a bit weird that the menu opens exactly once in its disabled state and then not anymore.
I hope anybody could explain to me, why exactly a disabled menu won't close and the property
StaysOpen at false makes it open exactly once, because it seems like a weird behaviour to me.