enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
982 stars 110 forks source link

Tabviews and PickerField #656

Closed dean-toolhound closed 3 weeks ago

dean-toolhound commented 3 weeks ago

I have a tabview with a contentview associated with each tab. On the second tab, which is not displayed until the tab is selected, there are pickerfields with the SelectedItem bound to a class.

<material:PickerField Title="Category" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" ItemDisplayBinding="{Binding Category}" ItemsSource="{Binding CategoryList}"/>

The SelectedCategory is set in the viewmodel before the second tab is displayed. When the second tab is loaded, the binding to the SelectedCategory does not work as nothing is selected in the picker. FYI, a regular picker also has the same results.

There are other non-pickerfield controls on the tab page that do bind properly.

The picker works fine otherwise as it shows the CategoryList and allows selection of a SelectedCategory. There is a pickerfield on the first tab that works as expected.

I have tried both CacheOnCodeBehind and CacheOnLayout caching strategies but it makes no difference. This has been tested on an Android emulator.

Any suggestions?

dean-toolhound commented 3 weeks ago

If I put the picker on the first tab, all works as expected.

dean-toolhound commented 3 weeks ago

Unbelievable but found the answer on another site. The order of the parameters matter. This works.

<material:PickerField x:Name="CategoryPicker" Title="Category" ItemsSource="{Binding CategoryList}" ItemDisplayBinding="{Binding Category}" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" />

An issue in Maui I believe.