Open Rosuavio opened 3 years ago
Does that even work in ListView
, it's usually odd for a collection to contain two copies of the same object?
In either case, if we need the index, we probably don't want to use Items.IndexOf(Item)
and instead use IndexFromContainer(ContainerFromItem(Item))
that may also handle this edge case?
Does that even work in
ListView
, it's usually odd for a collection to contain two copies of the same object?
I still have to make a sample to test this.
In either case, if we need the index, we probably don't want to use
Items.IndexOf(Item)
and instead useIndexFromContainer(ContainerFromItem(Item))
that may also handle this edge case?
I think it would be even better if we simply bound to the SelectedIndex
of the list rather than the SelectedItem
then we would lose no information of what the user clicked on.
Describe the bug
Because we bind the
SelectedItem
in theListView
to theSelectedItem
prop in theListDetailsView
when a user clicks an item it raises theOnSelectedItemChanged
method and it does not directly raise theOnSelectedIndexChanged
method. https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/5dfc5754a44bb5619fa083a4be4b5c240462e982/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.xaml#L156-L165This means the the index of the clicked item in the
ListView
is lost and then we incorrectly attempt to recover it and use it to update theSelectedIndex
prop. We get the index of the first reference to the object selected fromItems
but that is not necessarily the index item in the list the user clicked.https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/5dfc5754a44bb5619fa083a4be4b5c240462e982/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs#L148-L166
An example list where this could occur would look like.
TODO: Build real example.
A clear and concise description of what the bug is.
Steps to Reproduce
Steps to reproduce the behavior:
Expected behavior
Screenshots
Environment
NuGet Package(s):
Package Version(s):
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio version:
Additional context