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


C# Page.Layout方法代码示例

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


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

示例1: SetCurrent

		internal Task SetCurrent(Page page, bool animated, bool popping = false, Action completedCallback = null)
		{
			var tcs = new TaskCompletionSource<bool>();
			if (page == _currentDisplayedPage)
			{
				tcs.SetResult(true);
				return tcs.Task;
			}

			if (!animated)
				tcs.SetResult(true);

			page.Platform = this;

			if (GetRenderer(page) == null)
				SetRenderer(page, CreateRenderer(page));

			page.Layout(new Rectangle(0, 0, _renderer.ActualWidth, _renderer.ActualHeight));
			IVisualElementRenderer pageRenderer = GetRenderer(page);
			if (pageRenderer != null)
			{
				((FrameworkElement)pageRenderer.ContainerElement).Width = _renderer.ActualWidth;
				((FrameworkElement)pageRenderer.ContainerElement).Height = _renderer.ActualHeight;
			}

			Page current = _currentDisplayedPage;
			UIElement currentElement = null;
			if (current != null)
				currentElement = (UIElement)GetRenderer(current);

			if (popping)
			{
				ITransition transitionOut = null;
				if (current != null)
				{
					if (animated)
						transitionOut = _backwardOutTransition.GetTransition(currentElement);
					else
						_renderer.Children.Remove(currentElement);
				}

				var pageElement = (UIElement)GetRenderer(page);

				if (animated)
				{
					transitionOut.Completed += (s, e) =>
					{
						transitionOut.Stop();
						_renderer.Children.Remove(currentElement);
						UpdateToolbarTracker();

						_renderer.Children.Add(pageElement);

						ITransition transitionIn = _backwardInTransition.GetTransition(pageElement);
						transitionIn.Completed += (si, ei) =>
						{
							transitionIn.Stop();
							if (completedCallback != null)
								completedCallback();

							tcs.SetResult(true);
						};
						transitionIn.Begin();
					};

					transitionOut.Begin();
				}
				else
				{
					UpdateToolbarTracker();
					_renderer.Children.Add(pageElement);
					if (completedCallback != null)
						completedCallback();
				}
			}
			else
			{
				ITransition transitionOut = null;
				if (current != null)
				{
					if (animated)
						transitionOut = _forwardOutTransition.GetTransition(currentElement);
					else
						_renderer.Children.Remove(currentElement);
				}

				if (animated)
				{
					if (transitionOut != null)
					{
						transitionOut.Completed += (o, e) =>
						{
							_renderer.Children.Remove(currentElement);
							transitionOut.Stop();

							UpdateToolbarTracker();

							var element = (UIElement)GetRenderer(page);
							_renderer.Children.Add(element);
							ITransition transitionIn = _forwardInTransition.GetTransition(element);
//.........这里部分代码省略.........
开发者ID:cosullivan,项目名称:Xamarin.Forms,代码行数:101,代码来源:Platform.cs


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