diff --git a/src/Uno.Extensions.Reactive.UI.Tests/Presentation/Bindings/Collections/Given_BindableCollection_Selection.cs b/src/Uno.Extensions.Reactive.UI.Tests/Presentation/Bindings/Collections/Given_BindableCollection_Selection.cs index c9dfbbb664..2cb52be737 100644 --- a/src/Uno.Extensions.Reactive.UI.Tests/Presentation/Bindings/Collections/Given_BindableCollection_Selection.cs +++ b/src/Uno.Extensions.Reactive.UI.Tests/Presentation/Bindings/Collections/Given_BindableCollection_Selection.cs @@ -61,6 +61,19 @@ await TestHelper.WaitFor(async ct => }, CT); } + [TestMethod] + public async Task When_PreselectedItem_SelectedItems_ListView() + { + var (vm, lv, items) = await SetupListView(ListViewSelectionMode.Multiple); + + items[0].IsSelected = true; + + await TestHelper.WaitFor(async ct => + { + return (await vm.Items.GetSelectedItems(ct)).SequenceEqual(new MyItem[] { }); + }, CT); + } + [TestMethod] [InjectedPointer(PointerDeviceType.Mouse)] #if !__SKIA__ diff --git a/src/Uno.Extensions.Reactive.UI/Presentation/Bindings/Collections/Facets/SelectionFacet.cs b/src/Uno.Extensions.Reactive.UI/Presentation/Bindings/Collections/Facets/SelectionFacet.cs index 5895da507e..bd381d16b8 100644 --- a/src/Uno.Extensions.Reactive.UI/Presentation/Bindings/Collections/Facets/SelectionFacet.cs +++ b/src/Uno.Extensions.Reactive.UI/Presentation/Bindings/Collections/Facets/SelectionFacet.cs @@ -38,12 +38,19 @@ internal class SelectionFacet : IDisposable, ISelectionInfo private bool _isInit; - public SelectionFacet(IBindableCollectionViewSource source, CollectionChangedFacet collectionChangedFacet, Func < IObservableVector> target) + public SelectionFacet(IBindableCollectionViewSource source, CollectionChangedFacet collectionChangedFacet, Func > target) { _service = source.GetService(typeof(ISelectionService)) as ISelectionService; _target = new Lazy>(target, LazyThreadSafetyMode.None); _dispatcher = source.Dispatcher; _collectionChangedFacet = collectionChangedFacet; + +#if __WINDOWS__ + if (_service is not null) + { + UpdateLocalSelection(_service.GetSelectedRanges()); + } +#endif } private void Init()