I have a DataGrid in WPF bound to an observable collection. In my UI the User can add a new Element to the underlying collection. I want to selected the newly added item in my DataGrid, but depending on the current sorting of the DataGrid the item gets added at the bottom or at the top so using
grid.SelectedIndex = collection.Count - 1;
Does not work for all cases. Any ideas?
if you have a reference to the added item:
if you don’t have a reference: