views:

186

answers:

2

I have just started playing with Microsoft's 08/2010 WPF Ribbon release. The basics appear pretty straightforward, but how would I create a RibbonToggleButton group that would allow only one button in the group to be selected at one time, similar to the way that radio buttons are supposed to behave? Thanks for your help.

A: 

In the first version of the Microsoft WPF Ribbon bar we had to put some code in the code behind to get the desired single select toggle effect.

Steve
The new version is a complete rewrite. It supports MVVM and WPF conventions. I am sure it can be done in the new control in XAML.
David Veeneman
A: 

The (Ribbon)ToggleButton's behavior is not the same as a radio button's group where you can set a group and only one can be checked at a time. You'll need to write up a RibbonToggleButton.Checked event to handle the desired behavior. There's nothing wrong with this method (considering mvvm) since the code-behind is specifically dealing with UI behavior.

We had done a similar implementation using the first version of the Ribbon release:

  • create a RibbonGroup
  • add the RibbonToggleButtons to the RibbonGroup
  • wire up a Checked event to each button (they all share the same handler)

The checked event will find all the RibbonToggleButton's in the RibbonGroup and uncheck them, and then check the button being checked.

This may be another alternative How to get a group of toggle buttons to act like radio buttons in WPF?

Metro Smurf
I have used code-behind for UI stuff before, but I am trying to shift as much as is practical to XAML. The list box is the way I want to do it. I am working on an implementation and hope to have it done Thursday. I'll post it when I am done.
David Veeneman
ListBox XAML solution leaves it possible for there to be no selected button, which won't work for me--one button must always be selected. So, code-behind it is; answer accepted.
David Veeneman