-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Datagrid column sort is not reacting to databinding changes #10181
Comments
Live shaping, which I believe is the feature you are looking for, was introduced in .NET Framework 4.5 and is not enabled by default for performance reasons. You need to enable it on the collection view / source, see |
That works but why isn't there such a property on Datagrid itself? Datagrid allows binding to ObservableCollection. But only for a thing such as live sorting you have to bind Datagrid to an CollectionView which is created by an CollectionViewSource which is bound to your ObservableCollection? Seems unnecessarily overcomplicated to me. |
Features like sorting, grouping and filtering can be used on any control that displays lists of data (e.g. Let's imagine you have a single Now you can simply create a <CollectionViewSource x:Key="BookViewSource" Source="{Binding BookList}" IsLiveFilteringRequested="True">
<CollectionViewSource.LiveFilteringProperties>
<clr:String>IsReleased</clr:String>
</CollectionViewSource.LiveFilteringProperties>
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Title" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource> I would say this concept is a good compromise to give the flexibility to create as many collection views for the same list of data and reuse it as much as you need and want. Personally I tend to create I hope this makes sense. 😄 |
@Symbai are we good to close this issue? |
Makes sense EXCEPT the fact that Datagrid provides sorting on control level, by end user. This is different comparing to a Listbox. And I believe it should use live sorting by default. Because that is what the end user would expect. If you sort by filename in Windows explorer and then change a filename, it's properly sorted and not stuck like in WPF. And on other UI frameworks its the same. If there are performance concerns a developer would simply disallow sorting and sort by himself using CollectionViewSource. @himgoyalmicro Well while my original question has been answered, I'm currently trying to discuss whether we should change the behavior. |
Description
Has this been always the case? When I sort a column in a Datagrid by clicking on it, it only sorts the column once. If anything in the cells of the column changes, the column is not sorted again. I tried with and without CollectionView (but I didn't used the collectionview sort because if the Datagrid already has sorting I expect it to work on its own)
Shouldn't the column sort react to databinding changes? What's the purpose of allowing sort in WPF when, if it has to react on databinding changes, we have to add our own sorting instead?
Reproduction Steps
Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
.NET 8.0
x64
Other information
No response
The text was updated successfully, but these errors were encountered: