Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: initialize Windows localSelection (backport #2457) #2501

Open
wants to merge 2 commits into
base: release/stable/4.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ internal class SelectionFacet : IDisposable, ISelectionInfo

private bool _isInit;

public SelectionFacet(IBindableCollectionViewSource source, CollectionChangedFacet collectionChangedFacet, Func < IObservableVector<object>> target)
public SelectionFacet(IBindableCollectionViewSource source, CollectionChangedFacet collectionChangedFacet, Func <IObservableVector<object>> target)
{
_service = source.GetService(typeof(ISelectionService)) as ISelectionService;
_target = new Lazy<IObservableVector<object>>(target, LazyThreadSafetyMode.None);
_dispatcher = source.Dispatcher;
_collectionChangedFacet = collectionChangedFacet;

#if __WINDOWS__
if (_service is not null)
{
UpdateLocalSelection(_service.GetSelectedRanges());
}
#endif
}

private void Init()
Expand Down
Loading