开发者

SL4 radiobutton databinding

I have two separate groups of radiobuttons (which are populated at r开发者_Go百科un-time). the problem I'm facing is that the two groups behave as a single group i.e selecting something from one group deselects the selected item from the other group.

                    <ScrollViewer>
                        <ItemsControl ItemsSource="{Binding Path=AvailableX}" />
                    </ScrollViewer>
                    <ScrollViewer>
                        <ItemsControl ItemsSource="{Binding Path=AvailableY}" />
                    </ScrollViewer>


    public ObservableCollection<RadioButton> AvailableX
    {
        get
        {
            return _availableX;
        }
        set
        {
            _availableX = value;
        }
    }

    public ObservableCollection<RadioButton> AvailableY
    {
        get
        {
            return _availableY;
        }
        set
        {
            _availableY = value;
        }
    }

.....
.....

foreach (var x in _properties)
{
    AvailableX.Add(new RadioButton() { Content = x.ToString() });
    AvailableY.Add(new RadioButton() { Content = x.ToString() });
}


Try to set the group name:

new RadioButton() { Content = x.ToString(), GroupName = "X" });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜