1

I have a context menu that appears when a user right clicks which contains two menu items. The first item has a checkmark instead of the icon, and then a checkmark is placed on whichever one is clicked the next time the user right clicks. I have both IsCheckable and IsChecked set to 'False', but the checkmark still appears. Not sure what I'm doing wrong, any ideas?

This is the first time I right click, I don't want that check mark there.

First right-click

This is what shows if I selected "add waypoint" the first time, and right clicked again. It should show this every time, but if I ever click "add known object", the checkmark always appears.

After second right-click after hitting add waypoint

                <ContextMenu Name="nodeContextMenu" >
                    <MenuItem x:Name="ko" IsCheckable="False" IsChecked="False" Header="Add Known Object" Click="Ko_Click" >
                        <MenuItem.Icon>
                            <Image Source="ko.png" Height="7.5" Width="7.5" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem x:Name="wa" IsCheckable="False" IsChecked="False" Header="Add Waypoint" Click="Wa_Click" >
                        <MenuItem.Icon>
                            <Image Source="w.png" Height="7.5" Width="7.5" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
pfinferno
  • 1,779
  • 3
  • 34
  • 62
  • Do you have any implicit `Style`s active due to loaded themes? Such as ExpressionDark.xaml or whatever. A `Style` could be overriding how `IsCheckable` is being handled. – savetruman Feb 23 '15 at 18:24
  • Nope, no styles unless there's some default style that is set without me doing anything. I'm going to upload a few images to show what it's doing. – pfinferno Feb 23 '15 at 18:31
  • Added some images to clarify better. – pfinferno Feb 23 '15 at 18:44

2 Answers2

1

I found various elaborate WPF solutions for getting rid of the menu item checkmark to be really painful, so I ditched them all. Instead I solved it in a very simple way by having two menu items for what is effectively one menu item at runtime, and use Visibility=Collapsed to alternate between the two at runtime. This is incredibly simple whether you use bindings or events.

Bent Tranberg
  • 3,445
  • 26
  • 35
0

I used to have these menuitems as radio buttons, and had a method related to the radio buttons that did a function using the .IsChecked method. I had forgotten about that and it kept the first item checked every time. So I just got rid of it and it works fine. The snippet of code causing it is below:

knownObjectMenuItem.IsChecked = //random stuff
pfinferno
  • 1,779
  • 3
  • 34
  • 62