动态设置RadioButton的GroupName

时间:2017-04-06 13:11:56

标签: c# wpf xaml telerik

我正在动态添加控件,我想为无线电按钮设置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>

1 个答案:

答案 0 :(得分:2)

尝试使用您的集合中的某个唯一属性绑定组名,如下所示:GroupName="{Binding Id}"

相关问题