diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs new file mode 100644 index 00000000..6f0b0ea9 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3276.cs @@ -0,0 +1,91 @@ +using System; + +using Xamarin.Forms.CustomAttributes; +using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.ComponentModel; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls +{ + [Preserve (AllMembers = true)] + [Issue (IssueTracker.Github, 3276, "Crashing Unknown cell parent type on ContextAction Bindings")] + public class Issue3276 : TestTabbedPage + { + protected override void Init () + { + var listview = new ListView (); + listview.ItemTemplate = new DataTemplate (typeof(CaCell)); + + listview.SetBinding (ListView.ItemsSourceProperty, new Binding ("SearchResults")); + + var page = new ContentPage {Title = "First", Content = listview, BindingContext = new VM () }; + + page.Appearing += (object sender, EventArgs e) => (page.BindingContext as VM).Load (); + + Children.Add (page); + Children.Add (new ContentPage { Title = "Second" }); + } + + [Preserve (AllMembers = true)] + public class VM : ViewModel + { + public void Load () + { + var list = new List<string> (); + for (int i = 0; i < 20; i++) { + list.Add ("second " + i.ToString ()); + } + SearchResults = new ObservableCollection<string> (list); + } + + ObservableCollection<string> _list = null; + + public ObservableCollection<string> SearchResults { + get { return _list; } + + set { + _list = value; + OnPropertyChanged (); + } + } + + } + + [Preserve (AllMembers = true)] + public class CaCell : ViewCell + { + public CaCell () + { + var label = new Label (); + label.SetBinding (Label.TextProperty, new Binding (".")); + var menu = new MenuItem { Text = "Delete", IsDestructive = true }; + menu.SetBinding (MenuItem.CommandParameterProperty, new Binding (".")); + var menu1 = new MenuItem { Text = "Settings" }; + menu1.SetBinding (MenuItem.CommandParameterProperty, new Binding (".")); + ContextActions.Add (menu); + ContextActions.Add (menu1); + + var stack = new StackLayout (); + stack.Children.Add (label); + View = stack; + } + } + + + #if UITEST + [Test] + public void Issue3276Test () + { + RunningApp.Tap (q => q.Marked ("Second")); + RunningApp.Tap (q => q.Marked ("First")); + RunningApp.WaitForElement (q => q.Marked ("second 1")); + } +#endif + } +} |