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

[Android] [ListView] SelectedItem property doesn't get updated on selection changed #527

Closed
pdecostervgls opened this issue Jan 25, 2019 · 3 comments
Labels
kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform

Comments

@pdecostervgls
Copy link

I'm submitting a...

Bug report (I searched for similar issues and did not find one)

Current behavior

After selection a ListViewItem from a ListView, the property bound to Selecteditem of the ListView doesn't get changed on Android. Works on UWP.

Expected behavior

The property bound to the ListView's SelectedItem DP should get changed.

Minimal reproduction of the problem with instructions

Repro project @ https://github.com/pdecostervgls/Uno-SelectionChangedRepro

Environment

Nuget Package: 
Uno.UI : 1.43.0-dev.714

Affected platform(s):
- [ ] iOS
- [x] Android
- [ ] WebAssembly
- [ ] Windows
- [ ] Build tasks

Visual Studio
- [x] 2017 (version: 15.9.5)
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )

Relevant plugins
- [ ] Resharper (version: )
@pdecostervgls pdecostervgls changed the title [Android] ListView SelectedItem property doesn't get updated on selection changed [Android] [ListView] SelectedItem property doesn't get updated on selection changed Jan 25, 2019
@jeromelaban jeromelaban added the kind/bug Something isn't working label Jan 28, 2019
@jeromelaban
Copy link
Member

There's a #212 with the use of the DataContext property set tothis, which breaks bindings.

Could you try extracting the code with the ChosenItem property in another class, and set the DataContext to that ?

@pdecostervgls
Copy link
Author

pdecostervgls commented Jan 28, 2019

The repo is updated with the extracted version, which also fixes this issue. I created a new issue regarding the order of event firing. #534

@jeromelaban
Copy link
Member

After investigating a bit, the behavior of UWP is different depending if the selection is changed from the UI or programmatically. When done programmatically, the bindings to the Selector.SelectedItem property are updated after the event is raised, but when the list is interacted with by the user, the bindings are updated before.

Replicating this exact behavior is not an easy task as it may have important side effects in the DependencyObject behavior. I suggest you do not rely on this behavior, but rather on the properties of the list themselves.

In the process, I found out that the SelectionChanged event is raised twice, which will be adjusted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform
Projects
None yet
Development

No branches or pull requests

3 participants