From 724d6e1b23abd9b4974131bc6e70e1cb5ac7c017 Mon Sep 17 00:00:00 2001 From: Matthew Rajala Date: Fri, 19 Jul 2024 15:47:50 -0400 Subject: [PATCH 1/2] fix: localselection for windows --- .../Bindings/Collections/Facets/SelectionFacet.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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() From 119b71b60e1f53e5a61232a356c1c812135d3006 Mon Sep 17 00:00:00 2001 From: Matthew Rajala Date: Mon, 5 Aug 2024 10:55:35 -0400 Subject: [PATCH 2/2] chore: add test --- .../Given_BindableCollection_Selection.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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__