Cos
Cos

Reputation: 562

SL4 radiobutton databinding

I have two separate groups of radiobuttons (which are populated at run-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() });
}

Upvotes: 0

Views: 244

Answers (1)

Rumplin
Rumplin

Reputation: 2768

Try to set the group name:

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

Upvotes: 4

Related Questions