You have to use datagridview iteration to search for checked boxes. You should initiate this in your button click event handler. First we have to get all the rows of the datagrid :
public IEnumerable<Microsoft.Windows.Controls.DataGridRow> GetDataGridRows(Microsoft.Windows.Controls.DataGrid grid)
{
var itemsSource = grid.ItemsSource as IEnumerable;
if (null == itemsSource) yield return null;
foreach (var item in itemsSource)
{
var row = grid.ItemContainerGenerator.ContainerFromItem(item) as Microsoft.Windows.Controls.DataGridRow;
if (null != row) yield return row;
}
}
and then iterate through your grid:
var rows= GetDataGridRows(nameofyourdatagrid);
foreach (DataGridRow r in rows)
{
DataRowView rv = (DataRowView)r.Item;
if (r.Checked)
{
foreach (DataGridColumn column in nameofyordatagrid.Columns)
{
if (column.GetCellContent(r) is TextBlock)
{
TextBlock cellContent = column.GetCellContent(r) as TextBlock;
MessageBox.Show(cellContent.Text);
}
}
}
Of course, you could also add a similar method to an CellValueChanged Event , to automate the process. Hope this helps :)