diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2270.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2270.cs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2270.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2270.cs new file mode 100644 index 00000000..1c2a3a33 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2270.cs @@ -0,0 +1,77 @@ +using System.Collections.ObjectModel; +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Controls.TestCasesPages +{ + [Preserve (AllMembers=true)] + [Issue (IssueTracker.Github, 2270, "NSInternalCOnsistencyException when bound to ObservableCollection", PlatformAffected.iOS)] + public class Issue2270 : ContentPage + { + public Issue2270() + { + BindingContext = new TestListViewModel(); + + Padding = new Thickness(0, 40, 0, 0); + + var btn = new Button { + Text = "Load Data", + BorderWidth = 1, + BorderColor = Color.Gray, + }; + btn.SetBinding (Button.CommandProperty, "LoadDataCommand"); + + var lv = new ListView();// { IsGroupingEnabled = true }; + + var dt = new DataTemplate (typeof(TextCell)); + dt.SetBinding (TextCell.TextProperty, "Name"); + + lv.ItemTemplate = dt; + lv.SetBinding (ListView.ItemsSourceProperty, "Rows"); + + Content = new StackLayout { + Children = { + btn, + lv + } + }; + + } + + public class TestListViewModel + { + //public ObservableCollection<ObservableCollection<Row>> Rows { + public ObservableCollection<Row> Rows { + get; + set; + } + + public TestListViewModel () + { + //Rows = new ObservableCollection<ObservableCollection<Row>>(); + Rows = new ObservableCollection<Row>(); + } + + Command _command; + + public Command LoadDataCommand { + get { + return _command ?? (_command = new Command (LoadData)); + } + } + + void LoadData() { + Rows.Clear (); + + foreach (var row in new[] { new Row { Name = "one" }, new Row { Name = "Two" } }) { + Rows.Add (row); + } + } + + } + + public class Row + { + public string Name { get; set; } + } + } +} |