C# – Items collection must be empty before using ItemsSource with checkbox control in datagrid wpf

cwpfxaml

This error only occurs when I add this following XAML code :
enter image description here

 <DataGridTemplateColumn Header="Ist aktiv" IsReadOnly="True">
     <DataGridTemplateColumn.CellTemplate>
         <DataTemplate>
             <CheckBox IsChecked="{Binding IsActiveBool}"  />
          </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
 </DataGridTemplateColumn>

</DataGrid>

Best Answer

I also faced a similar problem for the first time, and I noticed you could even get this error message if you have forgot to add/enclose the

<DataGrid.Columns> </DataGrid.Columns>

tags

Related Topic