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


C# Grid.GetSizeRequest方法代码示例

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


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

示例1: TestSizeRequestWithPadding

		public void TestSizeRequestWithPadding ()
		{
			var platform = new UnitPlatform ();
			var layout = new Grid {Platform = platform, IsPlatformEnabled = true, Padding = new Thickness(20, 10, 15, 5)};
			layout.Children.AddVertical (new[] {
				new View {Platform = platform, IsPlatformEnabled = true},
				new View {Platform = platform, IsPlatformEnabled = true},
				new View {Platform = platform, IsPlatformEnabled = true}
			});

			var result = layout.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity).Request;
			Assert.AreEqual (new Size (135, 87), result);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:13,代码来源:GridTests.cs

示例2: TestStarLayout

		public void TestStarLayout ()
		{
			var platform = new UnitPlatform ();
			var layout = new Grid ();
			layout.Platform = platform;

			var label1 = new Label {Platform = platform, IsPlatformEnabled = true};
			var label2 = new Label {Platform = platform, IsPlatformEnabled = true};
			var label3 = new Label {Platform = platform, IsPlatformEnabled = true};

			layout.ColumnDefinitions = new ColumnDefinitionCollection { 
				new ColumnDefinition {Width = new GridLength (1, GridUnitType.Star)},
				new ColumnDefinition {Width = new GridLength (1, GridUnitType.Star)},
				new ColumnDefinition {Width = new GridLength (1, GridUnitType.Star)},
			};
			layout.RowDefinitions = new RowDefinitionCollection {
				new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
				new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
				new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
			};
			layout.Children.Add (label1, 0, 0);
			layout.Children.Add (label2, 1, 1);
			layout.Children.Add (label3, 2, 2);

			var request = layout.GetSizeRequest (1002, 462);
			Assert.AreEqual (312, request.Request.Width);
			Assert.AreEqual (72, request.Request.Height);

			layout.Layout (new Rectangle (0, 0, 1002, 462));
			Assert.AreEqual (1002, layout.Width);
			Assert.AreEqual (462, layout.Height);

			Assert.AreEqual (new Rectangle (0, 0, 330, 150), label1.Bounds);
			Assert.AreEqual (new Rectangle (336, 156, 330, 150), label2.Bounds);
			Assert.AreEqual (new Rectangle (672, 312, 330, 150), label3.Bounds);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:36,代码来源:GridTests.cs

示例3: TestLimitedHeightSizeRequest

		public void TestLimitedHeightSizeRequest ()
		{

			var platform = new UnitPlatform ();
			var layout = new Grid {Platform = platform, IsPlatformEnabled = true};
			layout.Children.AddVertical (new[] {
				new View {Platform = platform, IsPlatformEnabled = true},
				new View {Platform = platform, IsPlatformEnabled = true},
				new View {Platform = platform, IsPlatformEnabled = true}
			});

			var result = layout.GetSizeRequest (double.PositiveInfinity, 10).Request;
			Assert.AreEqual (new Size (100, 72), result);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:14,代码来源:GridTests.cs

示例4: TestZeroSizeConstraints

		public void TestZeroSizeConstraints ()
		{
			var layout = new Grid {Platform = new UnitPlatform ()};

			Assert.AreEqual (new Size (0, 0), layout.GetSizeRequest (0, 0).Request);
			Assert.AreEqual (new Size (0, 0), layout.GetSizeRequest (0, 10).Request);
			Assert.AreEqual (new Size (0, 0), layout.GetSizeRequest (10, 0).Request);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:GridTests.cs

示例5: ChangingRowHeightViaBindingTriggersRedraw

		//https://bugzilla.xamarin.com/show_bug.cgi?id=31967
		public void ChangingRowHeightViaBindingTriggersRedraw ()
		{
			var rowdef = new RowDefinition ();
			rowdef.SetBinding (RowDefinition.HeightProperty, "Height");
			var grid = new Grid {
//				RowDefinitions = new RowDefinitionCollection {
//					new RowDefinition { Height = GridLength.Auto },
//					rowdef
//				},
				RowSpacing = 0,
				Platform = new UnitPlatform (),
				IsPlatformEnabled = true,
			};
			grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto });
			grid.RowDefinitions.Add (rowdef);

			var label0 = new Label { IsPlatformEnabled = true };
			Grid.SetRow (label0, 0);
			var label1 = new Label { IsPlatformEnabled = true };
			Grid.SetRow (label1, 1);

			grid.BindingContext = new {Height = 0};
			grid.Children.Add (label0);
			grid.Children.Add (label1);

			Assert.AreEqual (new SizeRequest (new Size (100, 20), new Size (0, 20)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
			grid.BindingContext = new {Height = 42};
			Assert.AreEqual (new SizeRequest (new Size (100, 62), new Size (0, 62)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:30,代码来源:GridTests.cs

示例6: WidthBoundRequestRespected

		public void WidthBoundRequestRespected ()
		{
			var grid = new Grid {
				ColumnDefinitions = {
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
				},
				RowDefinitions = {
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto },
				},
				Platform = new UnitPlatform (GetResizableSize),
				IsPlatformEnabled = true,
				RowSpacing = 0,
				ColumnSpacing = 0,
			};

			var topLabel = new Editor {IsPlatformEnabled = true};
			var leftLabel = new Label {IsPlatformEnabled = true, WidthRequest = 10};
			var rightLabel = new Label {IsPlatformEnabled = true, WidthRequest = 10};

			grid.Children.Add (topLabel, 0, 2, 0, 1);
			grid.Children.Add (leftLabel, 0, 1);
			grid.Children.Add (rightLabel, 1, 1);

			var unboundRequest = grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity);
			var widthBoundRequest = grid.GetSizeRequest (50, double.PositiveInfinity);

			Assert.AreEqual (new SizeRequest (new Size (20, 120), new Size (0, 120)), unboundRequest);
			Assert.AreEqual (new SizeRequest (new Size (50, 60), new Size (0, 60)), widthBoundRequest);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:31,代码来源:GridTests.cs

示例7: SizeRequestForStar

		public void SizeRequestForStar ()
		{
			var platform = new UnitPlatform ();

			var grid = new Grid{ 
				RowDefinitions = new RowDefinitionCollection {
					new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
					new RowDefinition {Height = GridLength.Auto},
				},
				ColumnDefinitions = new ColumnDefinitionCollection {
					new ColumnDefinition {Width = new GridLength (1, GridUnitType.Star)},
					new ColumnDefinition {Width = GridLength.Auto},
				}
			};
			grid.Children.Add (new Label {BackgroundColor = Color.Lime, Text="Foo", Platform = platform, IsPlatformEnabled = true});
			grid.Children.Add (new Label {Text = "Bar", Platform = platform, IsPlatformEnabled = true},0,1);
			grid.Children.Add (new Label {Text="Baz",XAlign = TextAlignment.End, Platform = platform, IsPlatformEnabled = true},1,0);
			grid.Children.Add (new Label {Text="Qux", XAlign = TextAlignment.End, Platform = platform, IsPlatformEnabled = true},1,1);

			var request = grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity);
			Assert.AreEqual (206, request.Request.Width);
			Assert.AreEqual (46, request.Request.Height);

			Assert.AreEqual (106, request.Minimum.Width);
			Assert.AreEqual (26, request.Minimum.Height);
			//
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:27,代码来源:GridTests.cs


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