Exemplo n.º 1
0
        public void OnTemplatedViewApplyTemplateShouldBeCalled()
        {
            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.MyTestTemplatedView"">
					<ContentView.ControlTemplate>
						<ControlTemplate>
							<Label x:Name=""label0""/>
						</ControlTemplate>
					</ContentView.ControlTemplate>
				</ContentView>"                ;

            var contentView = new MyTestTemplatedView();

            contentView.LoadFromXaml(xaml);

            Assert.IsTrue(contentView.WasOnApplyTemplateCalled);
        }
Exemplo n.º 2
0
        public void GetTemplatedViewTemplateChildShouldWork()
        {
            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.MyTestTemplatedView"">
					<TemplatedView.ControlTemplate>
						<ControlTemplate>
							<Label x:Name=""label0""/>
						</ControlTemplate>
					</TemplatedView.ControlTemplate>
				</ContentView>"                ;

            var contentView = new MyTestTemplatedView();

            contentView.LoadFromXaml(xaml);

            IList <Element> internalChildren = contentView.InternalChildren;

            Assert.AreEqual(internalChildren[0], contentView.TemplateChildObtained);
        }