Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to reliably change the selected index of a Picker view from within SelectedIndexChanged

$
0
0

Under specific circumstances, when a user selects an item in a Picker, I need to move the selection to a different item in the same Picker (it sounds strange, but it makes perfect sense when you use it).

On Windows Phone the following code works fine, but on Android it is very fragile. I've had variants of this work on Android, but a minor tweak and it fails again, as if there is a timing issue. At the moment, it is failing again, by which I mean that the display is not updating to show the change of selection.

_myPicker.SelectedIndexChanged += (sender, args) =>
{
if (someConditionIsTrue)
_myPicker.SelectedIndex = aDifferentIndex;
}

How can I reliably change the SelectedIndex from within SelectedIndexChanged, so that the display reliably updates on Android, as well as Windows Phone and iOS?

Many thanks,

John H.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>