The following Xamarin Forms app that contains a Picker and a CollectionView controls bound to the same List of animals (Chicken and Cow). When I push the upgrade button the animals should upgrade to an Eagle and Elephant. The animals are upgraded, but the Picker doesn't reflect the change. The CollectionView works fine.
What am I doing wrong here? If needed, the source for this project can be found at Github.
Click to see demo
MainPage.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="SampleApp.MainPage">
<StackLayout Margin="0,100,0,0">
<Button Text="Upgrade Animals"
Margin="10"
HorizontalOptions="Center"
VerticalOptions="Start"
Command="{Binding Upgrade}" />
<Picker ItemsSource="{Binding Animals}" />
<CollectionView ItemsSource="{Binding Animals}" />
</StackLayout>
</ContentPage>
MainPageModel.cs
public class MainPageModel : INotifyPropertyChanged
{
public MainPageModel()
{
_Animals = new List<string>() { "Chicken", "Cow" };
}
private List<string> _Animals;
public List<string> Animals
{
get { return _Animals; }
set
{
_Animals = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Animals"));
}
}
public Command Upgrade
{
get
{
return new Command(_ =>
{
Animals = new List<string>() { "Eagle", "Elephant" };
});
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
UPDATE
The above code is running XF 4.3.0.908675. I downgraded to 4.2.0.778463, and the problem goes away. This might be a new bug introduced in the latest XF release.