问题描述
我目前正在构建一个将在触摸面板中使用的用户界面.因此,我想将任何 RadioButton 组显示为 ToggleButtons 的水平行.我已经想出了如何显示 ToggleButtons 而不是标准的项目符号:
I'm currently building a UI that is going to be used in a touch panel. Therefore, I would like to display any RadioButton groups as horizontal rows of ToggleButtons. I already figured out how to display ToggleButtons instead of the standard bullet items:
<Style x:Key="{x:Type RadioButton}"
TargetType="{x:Type RadioButton}"
BasedOn="{StaticResource {x:Type ToggleButton}}">
但是,这将显示一个列 ToggleButtons,而不是行.你知道一个简单的方法吗?
However, this will show a column of ToggleButtons, not a row.Do you know an easy way to do this?
非常感谢!
推荐答案
想通了:解决方案中不涉及 RadioButtons - 我不得不修改托管它们的 ItemsControl:
Figured it out: the RadioButtons are not involved in the solution - I had to modify the ItemsControl that hosted them:
<Style x:Key="myKey" TargetType="{x:Type ItemsControl}">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
IsItemsHost="True"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
这篇关于WPF:如何让 Radiobuttons 显示为 ToggleButtons 的水平行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!