當前位置: 首頁>>代碼示例>>C#>>正文


C# Label.GetSizeRequest方法代碼示例

本文整理匯總了C#中Xamarin.Forms.Label.GetSizeRequest方法的典型用法代碼示例。如果您正苦於以下問題:C# Label.GetSizeRequest方法的具體用法?C# Label.GetSizeRequest怎麽用?C# Label.GetSizeRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Xamarin.Forms.Label的用法示例。


在下文中一共展示了Label.GetSizeRequest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FontCalc

 public FontCalc(Label label, double fontSize, double containerWidth)
     : this()
 {
     // Save the font size.
     FontSize = fontSize;
     // Recalculate the Label height.
     label.FontSize = fontSize;
     SizeRequest sizeRequest = label.GetSizeRequest(containerWidth, Double.PositiveInfinity);
     // Save that height.
     TextHeight = sizeRequest.Request.Height;
     TextWidth = sizeRequest.Request.Width;
 }
開發者ID:kphillpotts,項目名稱:CuriousConverter,代碼行數:12,代碼來源:LabelViewExtensions.cs

示例2: StockStatsPage

		public StockStatsPage (string stockTicker)
		{
			var stock = new ChartingAndComparingPrices.ComparingStocks (stockTicker, new DateTime (2014, 1, 1), DateTime.Now);

			RelativeLayout relativeLayout = new RelativeLayout ();

			#region Views
			var largeTicker = new Label {
				Text = stockTicker.ToUpper (),
				FontSize = 30,
				FontAttributes = FontAttributes.Bold,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				TextColor = MyColors.Clouds,
				WidthRequest = 50,
				HeightRequest = 25
			};

			var standDevLabel = new Label { 
				Text = "Standard Deviation",
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				TextColor = MyColors.Clouds
			};

			var standDevNumber = new Label {
				Text = "$" + System.Math.Round (stock.StandardDev, 2).ToString (),
				HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = MyColors.Turqoise
			};

			var basicStatsLabel = new Label { 
				Text = "Basic Statistics using Math.Net",
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				TextColor = MyColors.Clouds
			};

			var meanLabel = new Label {
				Text = "Mean: ",
				HorizontalOptions = LayoutOptions.Start, TextColor = MyColors.Clouds
			};

			var mean = new Label {
				Text = "$" + System.Math.Round (stock.Mean, 2).ToString (),
				TextColor = MyColors.Turqoise
			};

			var maxLabel = new Label {
				Text = "Max: ",
				HorizontalOptions = LayoutOptions.Start, TextColor = MyColors.Clouds
			};

			var max = new Label {
				Text = "$" + System.Math.Round (stock.Max, 2),
				TextColor = MyColors.Turqoise
			};

			var minLabel = new Label {
				Text = "Min: ",
				HorizontalOptions = LayoutOptions.Start, TextColor = MyColors.Clouds
			};

			var min = new Label {
				Text = "$" + System.Math.Round (stock.Min, 2),
				TextColor = MyColors.Turqoise
			};

			var stdLabel = new Label {
				Text = "StdDev: ",
				HorizontalOptions = LayoutOptions.Start, TextColor = MyColors.Clouds
			};

			var stdDev = new Label {
				Text = "$" + System.Math.Round (stock.StandardDev, 2).ToString (),
				TextColor = MyColors.Turqoise
			};

			var boxView = new BoxView ();
			boxView.HeightRequest = 2;
			boxView.WidthRequest = App.ScreenWidth;
			boxView.Color = MyColors.Concrete;

			var boxView0 = new BoxView ();
			boxView0.HeightRequest = 1;
			boxView0.WidthRequest = App.ScreenWidth;
			boxView0.Color = MyColors.Concrete;

			var boxView1 = new BoxView ();
			boxView1.HeightRequest = 1;
			boxView1.WidthRequest = App.ScreenWidth;
			boxView1.Color = MyColors.Concrete;

			#endregion

			#region Find view sizes
			Func<RelativeLayout, double> standDevLabelWidth = (p) => standDevLabel.GetSizeRequest (relativeLayout.Width, relativeLayout.Height).Request.Width;

			Func<RelativeLayout, double> standDevNumberWidth = (p) => standDevNumber.GetSizeRequest (relativeLayout.Width, relativeLayout.Height).Request.Width;
			Func<RelativeLayout, double> standDevNumberHeight = (p) => standDevNumber.GetSizeRequest (relativeLayout.Width, relativeLayout.Height).Request.Height;

			Func<RelativeLayout, double> meanNumberWidth = (p) => mean.GetSizeRequest (relativeLayout.Width, relativeLayout.Height).Request.Width;

			Func<RelativeLayout, double> largeTickerWidth = (p) => largeTicker.GetSizeRequest (relativeLayout.Width, relativeLayout.Height).Request.Width;
//.........這裏部分代碼省略.........
開發者ID:IanLeatherbury,項目名稱:tryfsharpforms,代碼行數:101,代碼來源:StockStatsPage.cs


注:本文中的Xamarin.Forms.Label.GetSizeRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。