Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Expanding on the DataGridCell concept noted above, this is what we used to get it working.</p> <p>...XAML...</p> <pre><code> &lt;DataGrid Grid.ColumnSpan="2" Name="dgMissingNames" ItemsSource="{Binding Path=TheMissingChildren}" Style="{StaticResource NameListGrid}" SelectionChanged="DataGrid_SelectionChanged"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTemplateColumn CellStyle="{StaticResource NameListCol}"&gt; &lt;DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;CheckBox IsChecked="{Binding Path=Checked, UpdateSourceTrigger=PropertyChanged}" Name="theCheckbox" /&gt; &lt;/DataTemplate&gt; &lt;/DataGridTemplateColumn.CellTemplate&gt; &lt;/DataGridTemplateColumn&gt; &lt;DataGridTextColumn Binding="{Binding Path=SKU}" Header="Album" /&gt; &lt;DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" "/&gt; &lt;DataGridTextColumn Binding="{Binding Path=Pronunciation}" Header="Pronunciation" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>TheMissingChildren is an ObservableCollection object that contains the list of data elements including a boolean field "Checked" that we use to populate the datagrid.</p> <p>The SelectionChanged code here will set the checked boolean in the underlying TheMissingChildren object and fire off a refresh of the items list. That ensures that the box will get checked off &amp; display the new state no matter where you click on the row. Clicking the checkbox or somewhere in the row will toggle the check on/off.</p> <pre><code>private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid ThisGrid = (DataGrid)sender; CheckedMusicFile ThisMusicfile = (CheckedMusicFile)ThisGrid.SelectedItem; ThisMusicfile.Checked = !ThisMusicfile.Checked; ThisGrid.Items.Refresh(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload