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.

Matthew
  • 28,056
  • 26
  • 104
  • 170
  • This has been asked many times, but the SO search ain't the brightest. – H.B. Jun 06 '11 at 14:06
  • possible duplicate of [Mutually exclusive checkable menu items?](http://stackoverflow.com/questions/3652688/mutually-exclusive-checkable-menu-items) – H.B. Jun 06 '11 at 14:07
  • @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). – Matthew Jun 06 '11 at 14:12
  • 1
    That part of the question is the least of your problems, it's literally a cosmetic aspect. – H.B. Jun 06 '11 at 14:12
  • 2
    @H.B. The cosmetic aspect is important to me. – Matthew Jun 06 '11 at 14:14

2 Answers2

2

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

Rachel
  • 130,264
  • 66
  • 304
  • 490
  • 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. – Matthew Jun 06 '11 at 14:13
  • @Matthew 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. – Rachel Jun 06 '11 at 14:14
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://stackoverflow.com/a/11497189/375727

Community
  • 1
  • 1
Rhyous
  • 6,510
  • 2
  • 44
  • 50