This is a migrated thread and some comments may be shown as answers.

GridView and CheckBox

1 Answer 53 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hadrien
Top achievements
Rank 1
Hadrien asked on 14 Jan 2013, 11:09 AM
I have a GridView which has 3 columns:
  • CheckBox: if the row is active;
  • TextBlock: row id;
  • TextBlock: row name;

There are a object collection and a binding is made to the GridView.
Now when I active the checkBox, I would like have access to the row, ie, to the object which was allocate to the row.

This is the XAML code I have:
<telerik:RadGridView Grid.Row="0" Grid.Column="0" x:Name="mainRadGridView"
IsSynchronizedWithCurrentItem="True" IsReadOnly="True"
AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="" DataMemberBinding="{Binding isActive}" Width="Auto" >
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding isActive}"
 Checked="checkBox_Checked"
 Unchecked="checkBox_Unchecked"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="id" DataMemberBinding="{Binding id}" Width="Auto"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="name" DataMemberBinding="{Binding name}" Width="Auto"></telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>                                
</telerik:RadGridView>

Any suggestion?

1 Answer, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 14 Jan 2013, 11:59 AM
Hi,

Actually you have the object behind the row, it is row's DataContext. Since DataContext property is inheritable same DataContext is set to the CheckBox control.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Hadrien
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or