lepoco / lepoco/wpfui

DataGridCheckBoxColumn IsReadOnly="True" is ignored

Open
#709 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in a .NET 6 WPF UI DataGrid using DataGridCheckBoxColumn with IsReadOnly="True", then inspect the column's checkbox behavior and related styles. Done means the checkbox cannot change its checked state when the column is read-only, without requiring the reported workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.