summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-04-12 11:35:01 -0700
committerJason Smith <jason.smith@xamarin.com>2016-04-12 11:35:00 -0700
commit73defe491f11fc417a22eebcf805ee20df90045a (patch)
tree82d5587119d509c45837fd651381d24d824e39fd /Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs
parent76c8c57fb30621272e19d493787836ed8c322b9d (diff)
downloadxamarin-forms-73defe491f11fc417a22eebcf805ee20df90045a.tar.gz
xamarin-forms-73defe491f11fc417a22eebcf805ee20df90045a.tar.bz2
xamarin-forms-73defe491f11fc417a22eebcf805ee20df90045a.zip
[Core] Can bind properties in BindableObjects added to static resources in XAML (#58)
Resources that are `BindableObject`s will inherit the `Parent`'s `BindingContext` unless they are `Element`s that have non-null `Parent`s.
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs
new file mode 100644
index 00000000..efa78941
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla23942.xaml.cs
@@ -0,0 +1,111 @@
+using Xamarin.Forms;
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 23942, "Cannot bind properties in BindableObjects added to static resources in XAML", PlatformAffected.All)]
+ public partial class Bugzilla23942 : TestContentPage
+ {
+ [Preserve(AllMembers = true)]
+ public class TestViewModel : ViewModelBase
+ {
+ string _doesItWork;
+ public string DoesItWork
+ {
+ get
+ {
+ return _doesItWork;
+ }
+ set
+ {
+ _doesItWork = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+#if APP
+ public Bugzilla23942()
+ {
+ InitializeComponent();
+ }
+#endif
+
+ private void InitializeView()
+ {
+ TestViewModel vm = new TestViewModel() { DoesItWork = "initial binding works" };
+ BindingContext = vm;
+ vm.DoesItWork = "success";
+ }
+
+ protected override void Init()
+ {
+ InitializeView();
+ }
+
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+ var lbl = this.FindByName<Bugzilla23942Label>("label");
+ lbl.Text = lbl.Options.Text;
+ }
+
+#if UITEST
+ [Test]
+ public void Bugzilla23942Test()
+ {
+ RunningApp.WaitForElement(q => q.Marked("success"));
+ }
+#endif
+ }
+
+ [Preserve(AllMembers = true)]
+ public class Bugzilla23942Options : BindableObject
+ {
+ public static readonly BindableProperty TextProperty =
+ BindableProperty.Create(propertyName: nameof(Text),
+ returnType: typeof(string),
+ declaringType: typeof(Bugzilla23942Options),
+ defaultValue: default(string));
+
+ public string Text
+ {
+ get
+ {
+ return (string)GetValue(TextProperty);
+ }
+ set
+ {
+ SetValue(TextProperty, value);
+ }
+ }
+ }
+
+ [Preserve(AllMembers = true)]
+ public class Bugzilla23942Label : Label
+ {
+ public static readonly BindableProperty OptionsProperty =
+ BindableProperty.Create(propertyName: nameof(Options),
+ returnType: typeof(Bugzilla23942Options),
+ declaringType: typeof(Bugzilla23942Label),
+ defaultValue: default(Bugzilla23942Options));
+
+ public Bugzilla23942Options Options
+ {
+ get
+ {
+ return (Bugzilla23942Options)GetValue(OptionsProperty);
+ }
+ set
+ {
+ SetValue(OptionsProperty, value);
+ }
+ }
+ }
+}