dotnet/Documentation/compatibility/listboxitem-isselected-bind...

34 lines
1.2 KiB
Markdown
Raw Normal View History

## ListBoxItem IsSelected binding issue with ObservableCollection<T>.Move
### Scope
Minor
### Version Introduced
4.5
### Version Reverted
4.6
### Source Analyzer Status
Planned
### Change Description
Calling `ObservableCollection<T>.Move` on a collection bound to a ListBox with items selected can lead to erratic behavior with future selection or unselection of ListBox items
- [ ] Quirked
- [ ] Build-time break
### Recommended Action
Calling `ObservableCollection<T>.Remove` and `ObservableCollection<T>.Insert` instead of `ObservableCollection<T>.Move` will work around this issue. Alternatively, this issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework.
### Affected APIs
* ``M:System.Collections.ObjectModel.ObservableCollection`1.Move(System.Int32,System.Int32)``
* ``M:System.Collections.ObjectModel.ObservableCollection`1.MoveItem(System.Int32,System.Int32)``
### Category
Windows Presentation Foundation (WPF)
[More information](http://social.msdn.microsoft.com/Forums/en-US/afcbc8b3-a2f2-41e4-b402-2efc9eab1ffe/listboxitem-isselected-binding-issue-with-observablecollectiontmove?forum=wpf)
<!-- breaking change id: 102 -->