question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Scenario Day] Picker SelectedIndex property not working

See original GitHub issue

Description

Picker SelectedIndex property not working.

<Picker Title="Select a monkey"
            SelectedIndex="3">
        <Picker.Items>
            <x:String>Baboon</x:String>
            <x:String>Capuchin Monkey</x:String>
            <x:String>Blue Monkey</x:String>
            <x:String>Squirrel Monkey</x:String>
            <x:String>Golden Lion Tamarin</x:String>
            <x:String>Howler Monkey</x:String>
            <x:String>Japanese Macaque</x:String>
        </Picker.Items>
    </Picker>

image

Steps to Reproduce

  1. Create a new .NET MAUI from template.
  2. Paste the previous piece of code.
  3. Launch the App.

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Windows SDK 10.0.17134.0, Android 11

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
StephaneDelcroixcommented, Jul 28, 2023

I think it’s a matter of declaration order. Xaml respects the order in which you set the properties, and in the snippet the selected index is set before the items, at a time there are no items, and is probably coerced back to 0 or -1.

0reactions
XamlTestcommented, May 4, 2023

Verified this on Visual Studio Enterprise 17.6.0 Preview 6.0. Repro on Windows 11 and Android emulator (13.0-API 33) with Project: 7138.zip

Android: image

Windows: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

xamarin picker not binding
Since your Picker 's ItemsSource (TestList property) is of type List<Performance> , the SelectedItem property bound to the Picker must be of ...
Read more >
My TwoWay binding for selectedIndex of a Picker doesn't ...
I've got a picker in a page. I've bound its item source and displayItem which both work. However the binding I've made for...
Read more >
Picker.SelectedIndex Property (Xamarin.Forms)
Gets or sets the index of the selected item of the picker. This is a bindable property.
Read more >
SelectionModel (JavaFX 8)
Refers to the selected index property, which is used to indicate the currently selected index value in the selection model.
Read more >
ListPicker - NativeScript Docs
Gets or set the items collection of the ListPicker. The items property can be set to an array or an object defining length...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found