当前位置: 首页>>代码示例>>C#>>正文


C# ContentPage.Layout方法代码示例

本文整理汇总了C#中ContentPage.Layout方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPage.Layout方法的具体用法?C# ContentPage.Layout怎么用?C# ContentPage.Layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentPage的用法示例。


在下文中一共展示了ContentPage.Layout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestChildFillBehavior

		public void TestChildFillBehavior ()
		{
			var child = new Label ();
			Page root = new ContentPage {Content = child};
			root.IsPlatformEnabled = child.IsPlatformEnabled = true;

			root.Layout (new Rectangle (0, 0, 200, 500));

			Assert.AreEqual (child.Width, 200);
			Assert.AreEqual (child.Height, 500);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:11,代码来源:PageTests.cs

示例2: TestSizedChildBehavior

		public void TestSizedChildBehavior ()
		{
			var plat = new UnitPlatform ();
			var child = new Label {Platform = plat, IsPlatformEnabled = true, WidthRequest = 100, HorizontalOptions = LayoutOptions.Center};
			var root = new ContentPage {Platform = plat, IsPlatformEnabled = true, Content = child};
			
			root.Layout (new Rectangle (0, 0, 200, 500));

			Assert.AreEqual (50, child.X);
			Assert.AreEqual (100, child.Width);
			Assert.AreEqual (500, child.Height);

			child = new Label () {
				Platform = plat, IsPlatformEnabled = true, 
				HeightRequest = 100, 
				VerticalOptions = LayoutOptions.Center
			};

			root = new ContentPage {
				Platform = plat, IsPlatformEnabled = true, 
				Content = child
			};

			root.Layout (new Rectangle (0, 0, 200, 500));
			
			Assert.AreEqual (0, child.X);
			Assert.AreEqual (200, child.Y);
			Assert.AreEqual (200, child.Width);
			Assert.AreEqual (100, child.Height);

			child = new Label ();
			child.IsPlatformEnabled = true;
			child.HeightRequest = 100;
			
			root = new ContentPage {
				Content = child,
				Platform = plat, IsPlatformEnabled = true
			};

			root.Layout (new Rectangle (0, 0, 200, 500));
			
			Assert.AreEqual (0, child.X);
			Assert.AreEqual (0, child.Y);
			Assert.AreEqual (200, child.Width);
			Assert.AreEqual (500, child.Height);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:46,代码来源:PageTests.cs

示例3: TestLayoutWithContainerArea

		public void TestLayoutWithContainerArea ()
		{
			View child;
			var page = new ContentPage {
				Content = child = new View {
					WidthRequest = 100,
					HeightRequest = 200,
					IsPlatformEnabled = true
				},
				IsPlatformEnabled = true,
				Platform = new UnitPlatform ()
			};

			page.Layout (new Rectangle (0, 0, 800, 800));

			Assert.AreEqual (new Rectangle (0, 0, 800, 800), child.Bounds);

			page.ContainerArea = new Rectangle (10, 10, 30, 30);

			Assert.AreEqual (new Rectangle (10, 10, 30, 30), child.Bounds);

			page.Layout (new Rectangle (0, 0, 50, 50));

			Assert.AreEqual (new Rectangle (10, 10, 30, 30), child.Bounds);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:PageTests.cs

示例4: TestLayoutChildrenCenter

		public void TestLayoutChildrenCenter ()
		{
			View child;
			var page = new ContentPage {
				Content = child = new View {
					WidthRequest = 100,
					HeightRequest = 200,
					HorizontalOptions = LayoutOptions.Center,
					VerticalOptions = LayoutOptions.Center,
					IsPlatformEnabled = true
				},
				IsPlatformEnabled = true,
				Platform = new UnitPlatform ()
			};

			page.Layout (new Rectangle (0, 0, 800, 800));

			Assert.AreEqual (new Rectangle (350, 300, 100, 200), child.Bounds);

			page.Layout (new Rectangle (0, 0, 50, 50));

			Assert.AreEqual (new Rectangle (0, 0, 50, 50), child.Bounds);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:23,代码来源:PageTests.cs


注:本文中的ContentPage.Layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。