title: How to loop over the rows of a WPF toolkit Datagrid
body: <p>I have the next code where I defined a WPF toolkit datagrid control called dgQuery; I filled this one with information of a dataset, then I inserted a new checkbox column in dgQuery to check/uncheck some of the rows, I show part of my C# code: </p>
  
  <pre><code>dgQuery.DataContext = dS.Tables[0];
  
  DataGridTemplateColumn cbCol = new DataGridTemplateColumn();
  cbCol.Header = "Opc";
  FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CheckBox));
  Binding bind = new Binding("IsSelected");
  bind.Mode = BindingMode.TwoWay;
  factory.SetValue(CheckBox.IsCheckedProperty, bind);
  DataTemplate cellTemplate = new DataTemplate();
  cellTemplate.VisualTree = factory;
  cbCol.CellTemplate = cellTemplate;
  dgQuery.Columns.Insert(0, cbCol);
  </code></pre>
  
  <p>After checking/unchecking  into the new checkbox column of  the dgQuery rows I will click a button to save into a database only the rows I  checked. The question is, how can I develop the loop for reading all the rows of dgQuery and the condition that will let me know which rows have the checkbox checked/unchecked? Help me with an example, please.</p>
  
  <p>Thanks!!</p>