DataGridCheckBoxColumn IsReadOnly="True" is ignored
Nobody has claimed this yet.
- 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
- Use ui:DataGrid, add DataGrid.Columns, add DataGridCheckBoxColumn, and set a data source for DataGrid.
- Set property IsReadOnly="True" to DataGridCheckBoxColumn.
- Run the app.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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