Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't edit cells of datagrid with DataGridCollectionView in ItemsSource #15865

Open
BreakByBrick opened this issue May 30, 2024 · 3 comments · May be fixed by #16054
Open

Can't edit cells of datagrid with DataGridCollectionView in ItemsSource #15865

BreakByBrick opened this issue May 30, 2024 · 3 comments · May be fixed by #16054

Comments

@BreakByBrick
Copy link

Describe the bug

Hello!

When ItemsSource of DataGrid binded to DataGridCollectionView, cell editing by double click is not working.
But when ItemsSource binded to ObservableCollection, cell editing is working.

To Reproduce

https://github.com/BreakByBrick/Avalonia.Issue/tree/main/DataGrid.CantEditDataGridCollectionView

image

Expected behavior

Double click on DataGrid cell with ItemsSource binded to DataGridCollectionView, starts cell editing.

Avalonia version

11.0.10

OS

Windows

Additional context

No response

@timunie
Copy link
Contributor

timunie commented Jun 12, 2024

can you please try 11.1 beta?

@Abdesol
Copy link
Contributor

Abdesol commented Jun 18, 2024

can you please try 11.1 beta?

I just tested it out on the master branch. The issue is still around.

@Abdesol
Copy link
Contributor

Abdesol commented Jun 18, 2024

The issue persisted even when I was not using IReadOnlyList, because of the casting with parenthesis in the properties path internally. I have fixed that issue with the pull request I made today.
However, using IReadOnlyList will still make it uneditable since IReadOnly sets the ReadOnly property on the data grid column. It is working for you on the observable collection one because, it first changes to IEnumerable and then to ObservableCollection, in the process losing the read-only property.

The below referenced line of code is the one ultimately checking if it should be editable or not based on the list's property:
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs#L50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants