2011-09-07 69 views
0

我有兩個單獨的單選按鈕組(在運行時填充)。我面臨的問題是,這兩個羣體表現爲一個羣體,即從一個羣體中選擇某些內容會取消選擇另一個羣組中的所選項目。SL4單選按鈕數據綁定

    <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() }); 
} 

回答

4

嘗試設置組名稱:

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