Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to Uncheck Menuitem isCheked property in MenuItemClick event

$
0
0
I am able to check the menuitem but not able to uncheck and more over it showing previous check in the menuitem. Once I click on the another menuitem it doesn't uncheck the previous menuitem. I'm adding menuitem from code.
private void OnMenuItemClick(object sender, RoutedEventArgs e)
            {
                RoutedEventArgs args = e as RoutedEventArgs;
                MenuItem item = args.OriginalSource as MenuItem;
                string header = item.Header.ToString();
                if (header == "B1")
                {
                    btnMenu.Content = header;
                    item.IsChecked=true;
                }
                else if (header == "A1")
                {
                    btnMenu.Content = header;
                    item.IsChecked=true;
                }

            }


I am applying the same menuitems and its event handler for 4 buttons.So that if i select one menuitem for first button it will show check on menuitem,the checked menu item show appear when i click on second button.how can i achieve this?..Any suggestion.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>