简体   繁体   English

动态地为RadioButton设置GroupName

[英]Setting GroupName for RadioButton Dynamically

I am Adding Controls dynamically,I want to set the GroupName for radio buttton. 我正在动态添加控件,我想为广播按钮设置GroupName。

Each row has 3 radio buttons 每行有3个单选按钮

When I Click a button dynamically rows get added and I have set GroupName has OS 当我单击一个按钮时,会动态添加行,并且我已将GroupName设置为OS

So if I add ten Record also I am able to select only one in the added list 因此,如果我添加十个记录,我也只能在添加的列表中选择一个

I want to generate GroupName for each row. 我想为每一行生成GroupName

here tk extension is telerik 这是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>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为RadioButton将GroupName添加到ControlTemplate - How to add GroupName to ControlTemplate for RadioButton 如何在中继器中设置3个单选按钮及其组名 - How to set 3 radiobutton with its groupname in a repeater 我已经更改了单选按钮的模板。 但是groupname属性不起作用 - I have changed the Template for the radiobutton. but the groupname property doesnot work groupname在转发器asp.net中的多个单选按钮中不起作用 - groupname doesn't work in more than one radiobutton inside repeater asp.net 从RadioButton继承的WPF-CustomControl的分组仅与GroupName一起使用 - Grouping of WPF-CustomControl, which inherits from RadioButton, just works with GroupName 在asp.net中的C#代码中的GridView中设置动态创建的单选按钮的组名 - Set the groupname of dynamically created radio buttons in gridview in C# code in asp.net 如何访问更新面板中动态添加的单选按钮 - how to access dynamically added radiobutton in update panel 动态创建的Radiobutton列表未激活onselected - Dynamically created Radiobutton list not firing onselected 在Chrome中动态创建的单选按钮呈现为未选中状态 - Radiobutton created dynamically rendered as unchecked in Chrome 动态生成标签单击WPF中的动态生成的RadioButton时 - Generate Labels Dynamically On clicking Dynamically generated RadioButton in WPF
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM