Пример #1
0
        public void OnContentViewApplyTemplateShouldBeCalled()
        {
            var xaml = @"<ContentView
					xmlns=""http://schemas.microsoft.com/dotnet/2021/maui""
					xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
					x:Class=""Microsoft.Maui.Controls.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);
        }
Пример #2
0
        public void GetContentViewTemplateChildShouldWork()
        {
            var xaml = @"<ContentView
					xmlns=""http://schemas.microsoft.com/dotnet/2021/maui""
					xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
					x:Class=""Microsoft.Maui.Controls.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);
        }