Wednesday, October 31, 2012

Radio buttons unchecking

Radio buttons unchecking

I have a created a form for evaulaiton of employees. There is a question and multiple answers which can be checkBoxes, radioButtons, comboBoxes etc.

Which control to display is set by a templateSelector

<Selector.RadioButtonDataTemplate>      <DataTemplate>          <Grid HorizontalAlignment="Stretch">              <Grid.RowDefinitions>                  <RowDefinition MinHeight="30"/>                  <RowDefinition/>                  <RowDefinition Height="5"/>             </Grid.RowDefinitions>              <Grid.ColumnDefinitions>                  <ColumnDefinition Width="20"/>                  <ColumnDefinition Width="*"/>                  <ColumnDefinition Width="20"/>                  <ColumnDefinition Width="Auto"/>             </Grid.ColumnDefinitions>              <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="10">                  <ItemsControl ItemsSource="{Binding Options}" >                       <ItemsControl.ItemsPanel>                             <ItemsPanelTemplate>                                   <StackPanel Orientation="Vertical"/>                             </ItemsPanelTemplate>                        </ItemsControl.ItemsPanel>                        <ItemsControl.ItemTemplate>                             <DataTemplate>                                  <RadioButton  IsChecked="{Binding IsClicked,Mode=TwoWay}" Margin="0,0,10,0">                                      <TextBlock Text="{Binding Title}"/>                                  </RadioButton>                             </DataTemplate>                      </ItemsControl.ItemTemplate>                  </ItemsControl>              </StackPanel>          </Grid>     </DataTemplate> </RadioButtonDataTemplate> 

The problem now is if I check a radio button then all other are reset for some reason. I know that this is a normal behaviour if they are inside the same control (stackpanel/grid/etc) but they are in completly different grids. Any ideas?

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog