【问题标题】:Bound RadioButtonList绑定 RadioButtonList
【发布时间】:2013-02-18 18:31:19
【问题描述】:

有人可以帮助我吗? 我想在 ListBox 的 Datatemplate 中绑定 RadioButtons 列表,但它不充当 RadioButtonList,即它可以同时选择多个 RB。 我在网上查了,但找不到正确的答案 感谢您的帮助

我的 xaml 如下

 <ItemsControl x:Name="itcPayTypes" DockPanel.Dock="Top" BorderThickness="0">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Content="{Binding PayTypeName}"  Click="RadioButton_Click_1"/>
                        </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

【问题讨论】:

  • 欢迎来到 SO。拼写检查、格式和邮政编码。
  • 你说得对,我英语写得不好

标签: wpf listbox radio-button


【解决方案1】:

嗨,为所有 RadioButtons 设置相同的 GroupName。我希望这会有所帮助。

<StackPanel Orientation="Horizontal">
     <RadioButton Content="{Binding PayTypeName}" GroupName="abc" Click="RadioButton_Click_1"/>
</StackPanel>

【讨论】:

  • 它对我没有帮助,因为我不知道按钮如何出现在列表中,因为它是一个绑定列表
  • 感谢您的关注。我在问题中写了它
  • 似乎是一个很好的解决方案,我稍后会检查它,然后我投票答案,现在我正在做其他事情。还是谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-22
  • 1970-01-01
相关资源
最近更新 更多