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>
<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
What you are looking for is this:
< CheckBox IsChecked="{Binding Cell.Row.Data.IsSelected, RelativeSource={RelativeSource AncestorType={x:Type prim:RowSelectorCellControl}}}" />
This is under the assumption that you have an IsSelected property to the object your binding to.