Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top