WPF 功能区:切换按钮组?
我刚刚开始使用 Microsoft 的 08/2010 WPF 功能区 发布。基础知识看起来非常简单,但如何创建一个 RibbonToggleButton 组,该组一次只允许选择该组中的一个按钮,类似于单选按钮的行为方式?感谢您的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(Ribbon)ToggleButton 的行为与单选按钮组不同,在单选按钮组中您可以设置一个组,并且一次只能选中一个组。您需要编写一个
RibbonToggleButton.Checked
事件来处理所需的行为。这种方法没有任何问题(考虑 mvvm),因为隐藏代码专门处理 UI 行为。我们使用 Ribbon 版本的第一个版本完成了类似的实现:
事件将在RibbonGroup 并取消选中它们,然后选中正在选中的按钮。
这可能是另一种选择如何让一组切换按钮像 WPF 中的单选按钮一样工作?
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:
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?
在 Microsoft WPF Ribbon bar 的第一个版本中,我们必须在代码后面放置一些代码才能获得所需的单选切换效果。
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.