jeudi 18 mars 2021

CheckBox Black Square By default WPF C#

I'm defining a datagrid in WPF and I have two checkbox columns. The first one is working properly, but the second one is having a weird behavior. Before saying anything else, I'd like to say that both columns are equal (since I did copy and paste). As soon as I start my application, the first column is empty (without the check), but the second one appears like this:

Sample

If I click on the box, that black square disappears. If I click again on the same checkbox, a normal check appears:

Sample

This is the code I have in my xaml file:

 <DataGridTemplateColumn
        Header="Column2"
        Width="0.5*"
        HeaderStyle="{StaticResource HeaderColumnDataGridColumnHeader}"
        CellStyle="{StaticResource SingleClickEditing}">
        <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                    <Grid>
                        <CheckBox 
                              VerticalAlignment="Center"
                              HorizontalAlignment="Center"
                              IsChecked="{Binding PropertyName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        </CheckBox>
                     </Grid>
                </DataTemplate>
        </DataGridTemplateColumn.CellTemplate>
 </DataGridTemplateColumn>

The behavior that I'm expecting is that both checkboxes appear empty by default. Could somebody tell me how to fix this?

Thank you so much in advance.




Aucun commentaire:

Enregistrer un commentaire