public void OnApplyTemplateShouldBeCalled() { var xaml = @"<ContentView xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" x:Class=""Xamarin.Forms.Core.UnitTests.MyTestContentView""> <ContentView.ControlTemplate> <ControlTemplate> <Label x:Name=""label0""/> </ControlTemplate> </ContentView.ControlTemplate> </ContentView>" ; var contentView = new MyTestContentView(); contentView.LoadFromXaml(xaml); Assert.IsTrue(contentView.WasOnApplyTemplateCalled); }
public void GetContentViewTemplateChildShouldWork() { var xaml = @"<ContentView xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" x:Class=""Xamarin.Forms.Core.UnitTests.MyTestContentView""> <ContentView.ControlTemplate> <ControlTemplate> <Label x:Name=""label0""/> </ControlTemplate> </ContentView.ControlTemplate> </ContentView>" ; var contentView = new MyTestContentView(); contentView.LoadFromXaml(xaml); IList <Element> internalChildren = contentView.InternalChildren; Assert.AreEqual(internalChildren[0], contentView.TemplateChildObtained); }