Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
binding checkbox state to row selection
posted

Hi ,

 

I am trying to bind the state of a checkbox which is in the rowselector to the selected state of a row in a xam grid 

 

here is the example of how i do this with a list box .

 

 

ListBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2"  Height="120" HorizontalAlignment="Left"  Name="lbRoles_AU" VerticalAlignment="Top" Width="120" SelectionMode="Multiple">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <CheckBox x:Name="cbRole" Content="{Binding Path=RoleName}"  Height="16" HorizontalAlignment="Left"   VerticalAlignment="Center"
                                          IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource  AncestorType=ListBoxItem},Mode=TwoWay}"/>
 
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>


Here is the code i have so far. but i dont know what to put in the ancestor type.

<ig:XamGrid AutoGenerateColumns="False" Name="dgAddress" >

<ig:XamGrid.RowSelectorSettings>
                  <ig:RowSelectorSettings  Visibility="Visible" EnableRowNumbering="False"  >
 <ig:RowSelectorSettings.Style>
<Style TargetType="ContentControl">
 <Setter Property="ContentTemplate">
<Setter.Value>
 <DataTemplate>
<CheckBox  x:Name="cbRow" 
 Checked="cbRow_Checked"
Unchecked="cbRow_Unchecked"  
 MouseLeftButtonDown="cbRow_MouseLeftButtonDown"
 IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource AncestorType= ???????},Mode=TwoWay}" 
                                                                                           />
 </DataTemplate>
</Setter.Value>
  </Setter>
</Style>
 </ig:RowSelectorSettings.Style>                                                     
</ig:RowSelectorSettings>
 </ig:XamGrid.RowSelectorSettings>

 

 

 

Could someone please guide me in the right direction

 

Thanks 

Prakash