I set a CheckBox as template column in XamGrid like:
<ig:TemplateColumn Key="MyColumn"> <ig:TemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Text="{MyColumn}"/> </DataTemplate> </ig:TemplateColumn.HeaderTemplate> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <CheckBox IsChecked="{Binding MyColumn, Mode=TwoWay}" Checked="CheckBox_Checked" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn>
then in code for event handler CheckBox_Checked, I want to get the row data of the current row when user click on the CheckBox. How can I do it?
Hello benjaminswitzer,
You can try to iterate through all of the rows in the xamGrid1.Rows collection.
If you have any additional questions on this matter or if I have misunderstood you in any way please let me know.
Thank you. then how to get all rows of the XamGrid?
Also you can get the whole XamGrid row from the Clicked event as follows:
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
((sender as CheckBox).Parent as CellControl).Cell.Row.ToString();
}
If you need any additional assistance on this matter please let me know.
Hi,
The first thing that comes to my mind is to bind the Tag property of the CheckBox to the DataContext (which is the underlying data object):
<DataTemplate> <CheckBox IsChecked="{Binding MyColumn, Mode=TwoWay}" Checked="CheckBox_Checked" Tag="{Binding}"/> </DataTemplate>
And then in code-behind you can obtain the row data like this:
private void CheckBox_Checked(object sender, RoutedEventArgs e){ MyDataObject dataObject = ((CheckBox)sender).Tag as MyDataObject; // ...}
Hope this helps,