How can I create a group of radio menu items in WPF?
Asked Answered
S

2

6

WPF seems to be lacking a RadioMenuItem class or similar functionality. In Windows.Forms, menu items had a RadioChecked property, but WPF menu items only have IsChecked. I can put actual RadioButtons in a MenuItem, but this feels weird and looks awkward.

How can I create a group of menu items that function like radio buttons in a WPF menu? For reference, see the "Zoom" menu in IE8.

Selfevident answered 6/6, 2011 at 13:58 Comment(5)
This has been asked many times, but the SO search ain't the brightest.Mannos
possible duplicate of Mutually exclusive checkable menu items?Mannos
@H.B. that question is not a duplicate. It is very similar, but still deals with the IsChecked property (which draws a check mark) rather than a RadioChecked-type property (which would draw a circle).Selfevident
That part of the question is the least of your problems, it's literally a cosmetic aspect.Mannos
@H.B. The cosmetic aspect is important to me.Selfevident
P
2

Change the Template of the MenuItem to display a RadioButton instead of the standard display

Prepared answered 6/6, 2011 at 14:10 Comment(2)
I don't want to display a RadioButton. That is what I am during currently, but it is clunky. If you look at the IE8 menu that I used as an example, you will see that it is not an actual RadioButton, but a MenuItem with a circle as the icon for the active item.Selfevident
@Selfevident You would still change the Template to show the Circle instead of the standard display. You don't have to use an actual RadioButton object.Prepared
H
1

I found this and StatckOverflow post another post with Google and neither had an answer that worked for me.

You don't want to use the Template you want to use the ItemContainerStyle.

I put the answer on the other stack overflow post: https://mcmap.net/q/363774/-mutually-exclusive-checkable-menu-items

Hamel answered 16/7, 2012 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.