我有两组独立的radiobuttons(在运行时填充)。我面临的问题是这两个群体表现为一个群体,即从一个群体中选择某个群体会取消选择另一个群体中的所选群体。
<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() });
}
答案 0 :(得分:4)
尝试设置群组名称:
new RadioButton() { Content = x.ToString(), GroupName = "X" });