public void TestBindingPath() { var xaml = @" <StackLayout xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <StackLayout.Children> <Label x:Name=""label0"" Text=""{Binding text}""/> <Label x:Name=""label1"" Text=""{Binding Path=text}""/> </StackLayout.Children> </StackLayout>" ; var stacklayout = new StackLayout(); stacklayout.LoadFromXaml(xaml); var label0 = stacklayout.FindByName <Label> ("label0"); var label1 = stacklayout.FindByName <Label> ("label1"); Assert.AreEqual(Label.TextProperty.DefaultValue, label0.Text); Assert.AreEqual(Label.TextProperty.DefaultValue, label1.Text); stacklayout.BindingContext = new { text = "Foo" }; Assert.AreEqual("Foo", label0.Text); Assert.AreEqual("Foo", label1.Text); }
public void TestUnknownType() { var xaml = @" <StackLayout xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <StackLayout.Children> <CustomView /> </StackLayout.Children> </StackLayout>" ; var stacklayout = new StackLayout(); Assert.Throws(new XamlParseExceptionConstraint(6, 8), () => stacklayout.LoadFromXaml(xaml)); }
public void TestFindByXName() { var xaml = @" <StackLayout xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <StackLayout.Children> <Label x:Name=""label0"" Text=""Foo""/> </StackLayout.Children> </StackLayout>" ; var stacklayout = new StackLayout(); stacklayout.LoadFromXaml(xaml); var label = stacklayout.FindByName <Label> ("label0"); Assert.NotNull(label); Assert.AreEqual("Foo", label.Text); }
public void TestNonEmptyCollectionMembers() { var xaml = @" <StackLayout xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <StackLayout.Children> <Grid x:Name=""grid0""> </Grid> <Grid x:Name=""grid1""> </Grid> </StackLayout.Children> </StackLayout>" ; var stacklayout = new StackLayout(); stacklayout.LoadFromXaml(xaml); var grid0 = stacklayout.FindByName <Grid> ("grid0"); var grid1 = stacklayout.FindByName <Grid> ("grid1"); Assert.NotNull(grid0); Assert.NotNull(grid1); }