Datagrid column sort is not reacting to databinding changes
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### 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
1. Use code below
2. Launch app
3. Click on the column to sort
4. Press the button
```XAML
```
```C#
public partial class MainWindow : Window
{
public MainWindow()
{
DataContext = this;
InitializeComponent();
Items.Add(new MyData { Name = "Item 1" });
Items.Add(new MyData { Name = "Item 2" });
Items.Add(new MyData { Name = "Item 3" });
Items.Add(new MyData { Name = "Item 4" });
Items.Add(new MyData { Name = "Item 5" });
}
public ObservableCollection Items { get; } = new();
private void Button_Click(object sender, RoutedEventArgs e)
{
Items[2].Name = "Changed";
}
}
public class MyData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
string _Name;
public string Name
{
get => _Name;
set
{
if (value == _Name) return;
_Name = value;
OnPropertyChanged(nameof(Name));
}
}
}
```
### Expected behavior

### Actual behavior

### Regression?
_No response_
### Known Workarounds
_No response_
### Impact
_No response_
### Configuration
.NET 8.0
x64
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.