title: Disable specific DataGridCheckBoxColumn cells via ViewModel
body: <p>My MVVM project has this ViewModel:</p>
  
  <pre><code>class ListViewModel : ViewModelBase {
      public ObservableCollection&lt;ListItemviewModel&gt; Items { ... }
  }
  class ListItemViewModel : ViewModelBase {
      public String  Name      { ... }
      public Boolean IsChecked { ... }
      public Boolean IsEnabled { ... }
  }
  </code></pre>
  
  <p>Writing the XAML seemed straightforward:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn     Header="Name"       Binding="{Binding Name}" /&gt;
          &lt;DataGridCheckBoxColumn Header="Is checked" Binding="{Binding IsChecked}" /&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>However, how can I get it so when a <code>ListItemViewModel</code>'s <code>IsEnabled</code> property is <code>false</code> the <code>DataGridCheckBoxColumn</code>'s cell in that row is disabled?</p>
  
  <p>I tried setting <code>IsReadOnly={Binding IsDisabled}</code> (and adding an <code>IsDisabled</code> property to <code>ListItemViewModel</code>, however to no avail) - and I recognise that would disable/enable the whole column, not individual cells.</p>
  
  <p>I also tried these instructions ( <a href="https://stackoverflow.com/questions/19572984/how-to-disable-a-cell-in-a-datagrid-while-binding-to-an-observablecollection">How to disable a cell in a DataGrid while binding to an ObservableCollection</a> ):</p>
  
  <pre><code>&lt;DataGridCheckBoxColumn Header="Is checked" Binding="{Binding IsChecked}" /&gt;
      &lt;DataGridCheckBoxColumn.CellStyle&gt;
          &lt;Style TargetType="DataGridCell"&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding IsEnabled}" Value="False"&gt;
                      &lt;Setter Property="IsEnabled" Value="False" /&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/DataGridCheckBoxColumn.CellStyle&gt;
  </code></pre>
  
  <p>However this has no effect and no binding errors are displayed in the Output window.</p>