Fix selection when updating an item that moves to a new pos
This commit is contained in:
@@ -437,25 +437,9 @@ public partial class ObservableCollection<TItem> :
|
|||||||
|
|
||||||
TItem item = this[oldIndex];
|
TItem item = this[oldIndex];
|
||||||
|
|
||||||
bool selected = false;
|
|
||||||
if (item is ISelectable selectable)
|
|
||||||
{
|
|
||||||
selected = selectable.Selected;
|
|
||||||
SelectedItem = default;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveItem(oldIndex);
|
RemoveItem(oldIndex);
|
||||||
Insert(newIndex, item);
|
Insert(newIndex, item);
|
||||||
|
|
||||||
if (selected)
|
|
||||||
{
|
|
||||||
SelectedItem = item;
|
|
||||||
if (item is ISelectable selectable2)
|
|
||||||
{
|
|
||||||
selectable2.Selected = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user