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


C# StackLayout.ForceLayout方法代码示例

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


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

示例1: TabStripControl


//.........这里部分代码省略.........
			_buttonStack = new StackLayoutEx {
				Orientation = StackOrientation.Horizontal,
				Padding = 0,
				Spacing = 0,
				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions= LayoutOptions.FillAndExpand,
			};

			_indicator = new TabBarIndicator {
				VerticalOptions = LayoutOptions.End,
				HorizontalOptions = LayoutOptions.Start,
				BackgroundColor = (Color)TabIndicatorColorProperty.DefaultValue,
				HeightRequest = 6,
				WidthRequest = 0,
			};

			_tabControl = new NControlView{
				BackgroundColor = TabBackColor,
				Content = new Grid{
					Padding = 0,
					ColumnSpacing = 0,
					RowSpacing=0,
					Children = {
						_buttonStack,
						_indicator,
					}
				}
			};

			_mainLayout.Children.Add (_tabControl, () => new Rectangle (
				0, 0, _mainLayout.Width, TabHeight)
			);

			// Create content control
			_contentView = new Grid {
				ColumnSpacing = 0,
				RowSpacing = 0,
				Padding = 0,
				BackgroundColor = Color.Transparent,
			};

			_mainLayout.Children.Add (_contentView, () => new Rectangle (
				0, TabHeight, _mainLayout.Width, _mainLayout.Height-TabHeight)
			);

			_children.CollectionChanged += (sender, e) => {

				_contentView.Children.Clear();
				_buttonStack.Children.Clear();

				foreach(var tabChild in Children)
				{
					var tabItemControl = new TabBarButton(tabChild.Title);
					if(FontFamily != null)
						tabItemControl.FontFamily = FontFamily;

					tabItemControl.FontSize = FontSize;
					tabItemControl.SelectedColor = TabIndicatorColor;						
					_buttonStack.Children.Add(tabItemControl);
				}

				if(Children.Any())
					Activate(Children.First(), false);
			};

			// Border
			var border = new NControlView {
				DrawingFunction = (canvas, rect) => {

					canvas.DrawPath (new NGraphics.PathOp[]{
						new NGraphics.MoveTo(0, 0),
						new NGraphics.LineTo(rect.Width, 0)
					}, NGraphics.Pens.Gray, null);
				},
			};

			_mainLayout.Children.Add (border, () => new Rectangle(
				0, TabHeight, _mainLayout.Width, 1));

			// Shadow
			_shadow = new NControlView {				
				DrawingFunction = (canvas, rect)=> {

					canvas.DrawRectangle(rect, null, new NGraphics.LinearGradientBrush(
						new NGraphics.Point(0.5, 0.0), new NGraphics.Point(0.5, 1.0),
						Color.Black.MultiplyAlpha(0.3).ToNColor(), NGraphics.Colors.Clear, 
						NGraphics.Colors.Clear));
				}
			};

			_mainLayout.Children.Add (_shadow, () => new Rectangle(
				0, TabHeight, _mainLayout.Width, 6));

			_shadow.IsVisible = false;

			SizeChanged += (object sender, EventArgs e) => {
				_buttonStack.ForceLayout();
				ForceLayout();
			};
		}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:101,代码来源:TabStripControl.cs

示例2: ExerciseContainerPage


//.........这里部分代码省略.........
									Frame exerciseFrame = new Frame();

						
									exerciseFrame = await GetExerciseFrame(exercise);
									nestedStackLayout.Children.Add(exerciseFrame);
									nestedStackScrollView.Content = nestedStackLayout;
									nestedStackScrollView.Parent = primaryStackLayout;
								}


								//Remove any previously seleced scrollviews
								int removeCount = 0;
								View removedItem = new ScrollView();
								bool scrollViewItemRemoved = false;
								foreach (var item in primaryStackLayout.Children)
								{
									//remove any previously opened scrollviews of exercises
									if (item is ScrollView)
									{
										removedItem = item;
										scrollViewItemRemoved = true;
										break;
									}
									removeCount++;

								}
								if (scrollViewItemRemoved)
								{

									//change state of bodypart frame to unselected
									Frame parentPartFrame = (Frame)primaryStackLayout.Children[removeCount - 1];
									parentPartFrame.Opacity = 1;
									primaryStackLayout.Children.Remove(removedItem);
									primaryStackLayout.ForceLayout();
								}

								int count = 1;
								int insertCount = 0;
								foreach (var item in primaryStackLayout.Children)
								{
									if (item == s)
									{
										insertCount = count;
										break;
									}
									count++;
								}


								primaryStackLayout.Children.Insert(insertCount, nestedStackScrollView);


							}
							else
							{
								//Remove exercises in bodypart and reset opacity
								clickedFrame.Opacity = 1;
								int count = 1;
								foreach (var item in primaryStackLayout.Children)
								{
									if (item == s)
									{
										break;
									}
									count++;
								}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:67,代码来源:ExerciseContainerPage.cs


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