Picker does not select an item when SelectedItem precedes ItemsSource in XAML attributes order
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 296
Description
### Description
It appears that the XAML attribute order is important when binding the SelectedItem and ItemsSource.
If ItemsSource is first, followed by SelectedItem the picker will properly select the item.
If the order is reversed, the picker does not select the item.
My expectation is that the XAML attribute order should not matter and the picker should properly select the item in both scenarios.
### Steps to Reproduce
Run the reproduction project.
The main page contains two pickers:
- the first is "broken" - the SelectedItem attribute is specified first, followed by ItemsSource.
- the second is working properly - the ItemsSource attribute is specified first, followed by SelectedItem.
Change the order of the SelectedItem and ItemsSource attributes of the "broken" picker. Notice how it now selects the proper item.
### Link to public reproduction project repository
https://github.com/valentinba/PickerBindingsOrderBug
### Version with bug
9.0.90 SR9
### Is this a regression from previous behavior?
Not sure, did not test other versions
### Last version that worked well
_No response_
### Affected platforms
Android, Windows, iOS
### Affected platform versions
Android 21.0, Windows 10.0.17763.0, iOS 15
### Did you find any workaround?
Changing the attributes order seems to fix the issue.
### Relevant log output
```shell
```
Contributor guide
Research direction
Start with the linked PickerBindingsOrderBug reproduction and compare the two Picker declarations, where SelectedItem and ItemsSource appear in opposite orders. Trace the corresponding Picker binding behavior in .NET MAUI; done means both declarations select the expected item on Android, Windows, and iOS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop, frontend, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100