Resolved Opening Context Menu Causes Content to Uncheck

glasswizzard

Well-known member
Joined
Nov 22, 2019
Messages
126
Programming Experience
Beginner
I made a context menu on a window with three items that are checkable in the menu, the top one is checked by default. When I right click on the window the menu opens but the top menu item is clicked, causing it to uncheck.

I have the IsChecked attributes of the menuitems binded to properties in my vm and each menu item simply shows a window or closes it, depending on whether the choice is already checked or not.

This is caused by that tunneling/bubbling bussiness with WPF events isn't it?
 
If you truly have used databinding, then the tunnelling/bubbling shouldn't matter. You only have to worry about it if you are implementing a control and need to override its event handlers and you are handling events yourself.
 
Being able to eyeball your model, bindings and the rest of your code would be useful to identify a possible problem. Sounds like a logic problem currently
 
You know what, it doesn't matter about this problem. All I had to do was make the menu items non checkable and everything works. While I would have liked to go through it just for curiosity's sake I've modified my code too much at this point. My bad for making a pointless thread.
 
No bother at all. However, if you are using a model, you likely reversed your logic problem. Where all you likely had to do was change your checkstate logic for your checkstate in the XAML, than in your model/code-behind C# file. I'm just assuming, but it sounds like, you wrote some contradicting logic regarding the checkstates. Never the less if its working as intended now, then leave it as is.
 
Back
Top Bottom