Skip to content

DataGridCheckBoxColumn IsReadOnly="True" is ignored #709

@Eterance

Description

@Eterance

Describe the bug

When using ui:DataGrid, even if IsReadOnly="True" is set for DataGridCheckBoxColumn, the checkbox can still be changed.

To Reproduce

  1. Use ui:DataGrid, add DataGrid.Columns, add DataGridCheckBoxColumn, and set a data source for DataGrid.
  2. Set property IsReadOnly="True" to DataGridCheckBoxColumn.
  3. Run the app.
  4. You can see that the checkbox inside DataGridCheckBoxColumn can still be modified to change its checked state.

Expected behavior

While IsReadOnly="True", the checkbox inside DataGridCheckBoxColumn should be ReadOnly.

Screenshots

No response

OS version

Windows 10, Version 19045.3031

.NET version

.NET 6

WPF-UI NuGet version

3.0.0-preview.4

Additional context

It seems there is a potential solution available at: https://stackoverflow.com/a/37584805
Currently, I am using the following workaround to bypass this bug.
First, add the following style in the resources:

<Style x:Key="DataGridCheckBoxColumnStyle" BasedOn="{StaticResource DataGridCheckBoxElementDefaultStyle}" TargetType="{x:Type CheckBox}">
    <Setter Property="IsHitTestVisible" Value="False"/>
</Style>

Then apply the style to the DataGridCheckBoxColumn:

<DataGridCheckBoxColumn ElementStyle="{StaticResource DataGridCheckBoxColumnStyle}" />

The drawback is that the checkbox requires two clicks to be modified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions