【问题标题】:Setting GroupName for RadioButton Dynamically为 RadioButton 动态设置 GroupName
【发布时间】:2017-04-06 13:11:56
【问题描述】:

我正在动态添加控件,我想为单选按钮设置 GroupName。

每行有 3 个单选按钮

当我点击一个按钮时动态添加行并且我设置了 GroupName 有操作系统

所以如果我添加十条记录,我也只能在添加的列表中选择一条

我想为每一行生成 GroupName

这里的 tk 扩展名是telerik

<tk:RadGridView ItemsSource="{Binding Collection}">          
            <tk:RadGridView.Columns>
                <tk:GridViewDataColumn Header="1" DataMemberBinding="{Binding Ask}" >
                    <tk:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                                <RadioButton GroupName="os" HorizontalContentAlignment="Center" />
                        </DataTemplate>
                    </tk:GridViewDataColumn.CellTemplate>
                </tk:GridViewDataColumn>
                <tk:GridViewDataColumn Header="2" DataMemberBinding="{Binding welcome}}">
                    <tk:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <RadioButton GroupName="os"/>
                        </DataTemplate>
                    </tk:GridViewDataColumn.CellTemplate>
                </tk:GridViewDataColumn>
                <tk:GridViewDataColumn Header="3" DataMemberBinding="{Binding there}">
                    <tk:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <RadioButton GroupName="os"/>
                        </DataTemplate>
                    </tk:GridViewDataColumn.CellTemplate>
                </tk:GridViewDataColumn>
            </tk:RadGridView.Columns>
        </tk:RadGridView>

【问题讨论】:

    标签: c# wpf xaml telerik


    【解决方案1】:

    尝试将组名与您集合中的某些独特属性绑定,例如:GroupName="{Binding Id}"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-23
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      • 2015-12-11
      • 2011-11-01
      相关资源
      最近更新 更多