I've constructed a DataGrid
by adding columns programatically using the following snippet:
var check = new FrameworkElementFactory(typeof(CheckBox), "chkBxDetail");
dgDetalle.Columns.Add(new DataGridTemplateColumn() { CellTemplate =
new DataTemplate() { VisualTree = check } });
for (int i = 0; i < 4; i++)
{
DataGridTextColumn textColumn = new DataGridTextColumn();
textColumn.Binding = new Binding(string.Format("[{0}]", i));
dgDetalle.Columns.Add(textColumn);
}
How can I know the checked/unckecked status of the checkboxes on the grid?
UPDATE I can't use binding
Finally I got it...
I created the
DataGrid
using this snippet:Then, I made a snippet to show data from selected items in a
MessageBox
:To summarize:
ItemContainerGenerator
DataGrid
and take it as a generic presentation object (FrameworkElement
)VisualTreeHelper
. Notice that I got theCheckBox
I've created on the first snippetHope it helps anyone...!