Hi,
I think that Martin Smith looks as though he's on the right track.
To satisfy your criteria of selecting the whole row, you might want to create a Dependency Property in your "Code Behind" of type "bool" and bind the "IsChecked" value of your Checkbox and the corresponding row in your data template to that value.
Unless this is due to an unknown constraint I would suggest that you don't use the Checkbox as a three-state checkbox as the third state is null and this might cause problems. I might be wrong on that front though.
#region CheckRow
public static readonly DependencyProperty CheckRowProperty =
DependencyProperty.Register("CheckRow", typeof(bool), typeof(Program),
new FrameworkPropertyMetadata((bool)false));
public bool CheckRow
{
get { return (bool)GetValue(CheckRowProperty); }
set { SetValue(CheckRowProperty, value); }
}
#endregion
Two things to remember when taking this approach however.
- The binding in the XAML must be "TwoWay".
- If your code behind is naive to the class containing the DataTable, you must set the data-context such that it points to where-ever your Dependency property resides.
< CheckBox Margin="10,0,0,0" IsChecked="{Binding Path=CheckRow, Mode="TwoWay"}"/>
The row in the DataTable must also be bound to this value.
I hope this helps.
Larrythemule