mercredi 29 avril 2015

Grouping CheckBoxes in XAML

I have a ListView which has an item template of a UserControl

This User Control decides which type of control to display for the template for each individual list item (Radio, or Checkbox).

<ListView Visibility="Collapsed"
          ItemsSource="{Binding Collection}"
          SelectionMode="None"
          Grid.Row="1">
          <ListView.ItemTemplate>
              <DataTemplate>            
                   <local:ucMyUserControl/>  
               </DataTemplate>
          </ListView.ItemTemplate>
</ListView>

So, in my user control based on the logic in the code behind, I display one of these

    <CheckBox  x:Name="chkOption"
               Content="{Binding Text}" 
               Visibility="Collapsed"
               />

    <RadioButton x:Name="rdoOption"
                 Content="{Binding Text}"
                 GroupName="radioGroup"                   
                 Visibility="Collapsed"
                 />

The problem I have is, the check boxes are acting like Radio boxes, in that if you select one, and then a second, the first one gets unchecked. The radio boxes are working just as expected but I can't work out what's going wrong. Do the Check boxes somehow need to be in a group like the radio boxes or is it something else?




Aucun commentaire:

Enregistrer un commentaire