--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Controls.Issues.Bugzilla51642">
+ <StackLayout>
+
+ <Picker>
+ <Picker.Items>
+ <x:String>1</x:String>
+ <x:String>2</x:String>
+ <x:String>3</x:String>
+ </Picker.Items>
+ </Picker>
+ <Picker ItemsSource="{Binding Items}"/>
+
+ </StackLayout>
+</ContentPage>
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 51642, "Delayed BindablePicker UWP", PlatformAffected.All)]
+ public partial class Bugzilla51642 : ContentPage
+ {
+ public Bugzilla51642 ()
+ {
+ InitializeComponent ();
+ LoadDelayedVM();
+ }
+
+ public async void LoadDelayedVM()
+ {
+ await Task.Delay(1000);
+ Device.BeginInvokeOnMainThread(() => BindingContext = new Bz51642VM());
+ }
+ }
+
+ class Bz51642VM
+ {
+ public IList<string> Items {
+ get {
+ return new List<String> { "Foo", "Bar", "Baz" };
+ }
+ }
+ }
+}
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla48236.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla47971.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla51238.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51642.xaml.cs">
+ <DependentUpon>Bugzilla51642.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla51642.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ </ItemGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
using Xamarin.Forms.Platform;
namespace Xamarin.Forms
return _platformConfigurationRegistry.Value.On<T>();
}
- class LockableObservableListWrapper : INotifyCollectionChanged, IList<string>
+ internal class LockableObservableListWrapper : IList<string>, ICollection<string>, INotifyCollectionChanged, INotifyPropertyChanged, IReadOnlyList<string>, IReadOnlyCollection<string>, IEnumerable<string>, IEnumerable
{
- readonly ObservableList<string> _list = new ObservableList<string>();
+ internal readonly ObservableCollection<string> _list = new ObservableCollection<string>();
- public bool IsLocked { get; set; }
+ event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged
+ {
+ add { ((INotifyCollectionChanged)_list).CollectionChanged += value; }
+ remove { ((INotifyCollectionChanged)_list).CollectionChanged -= value; }
+ }
- event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged {
- add { _list.CollectionChanged += value; }
- remove { _list.CollectionChanged -= value; }
+ event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged {
+ add { ((INotifyPropertyChanged)_list).PropertyChanged += value; }
+ remove { ((INotifyPropertyChanged)_list).PropertyChanged -= value; }
}
+ public bool IsLocked { get; set; }
+
void ThrowOnLocked()
{
if (IsLocked)
throw new InvalidOperationException("The Items list can not be manipulated if the ItemsSource property is set");
-
}
+
public string this [int index] {
get { return _list [index]; }
set {
Control.Loaded += ControlOnLoaded;
}
- Control.ItemsSource = Element.Items;
+ Control.ItemsSource = ((Picker.LockableObservableListWrapper)Element.Items)._list;
UpdateTitle();
UpdateSelectedIndex();