WPF Ribbon: ToggleButton groups?
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 sel开发者_Python百科ected at one time, similar to the way that radio buttons are supposed to behave? Thanks for your help.
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?
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.
精彩评论