DataGridCheckBoxColumn question, please help

Feb 2, 2009 at 10:12 PM
Hi, I have been trying to figure this out for whole day and it really drives me nuts....since I am very very new for WPF, I really need some help, please....
Here is my question.

I have a datagrid and the check box column will dynamicly add on when datagrid is loading. User can select only one row at one time. 



my:DataGrid Name="gvTest" xmlns:my="" ItemsSource="{Binding Tables[0]}" SelectedCellsChanged="gvTest_SelectedCellsChanged" >
<my:DataGridCheckBoxColumn Header="Checked" x:Name="chkSelected">




private void gvTest_SelectedCellsChanged(object sender, Microsoft.Windows.Controls.SelectedCellsChangedEventArgs e)


foreach (DataGridRow row in gvTest.Items) --Unable to cast object of type 'System.Data.DataRowView' to type 'Microsoft.Windows.Controls.DataGridRow'.


DataGridCheckBoxColumn chk = row.FindName("chkSelected") as DataGridCheckBoxColumn  
if(chk.Checked) -- I want to see if the check box is checked.
btn.DataContext = "Hello";





Feb 4, 2009 at 1:12 PM
Take a look at the GetRow and GetCell methods here,