Reputation: 25631
I have the following XAML for a MenuItem:
<MenuItem x:Name="CustomMenuItem"
Command="{Binding Path=Command, Mode=OneWay}">
<MenuItem.Header>
<ContentPresenter x:Name="MenuContentControl"
Content="{Binding Path=Content, Mode=OneWay}"/>
</MenuItem.Header>
</MenuItem>
The menu is rendered correctly and I can see the Command firing but the menu does not close afterwards, why is this and how can I make it close?
Upvotes: 0
Views: 213
Reputation: 81243
By default ContextMenu
closes on any click of menuItem.
But, however since you haven't posted more of your XAML code here. I suspect at top level or on this MenuItem you must have set StaysOpenOnClick to true.
<MenuItem Header="submenuitem1"
StaysOpenOnClick="true"
IsCheckable="true"/>
Remove that value if set or set that to false which is default value for all menu items.
Upvotes: 2