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


C# FrameworkElement.UpdateLayout方法代码示例

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


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

示例1: GoToStateCore

 protected override bool GoToStateCore(Control control, FrameworkElement templateRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
 {
     if (control == null)
     {
         control = new ContentControl();
     }
     if ((group == null) || (state == null))
     {
         return false;
     }
     if (!GetUseFluidLayout(group))
     {
         return base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
     }
     VisualState currentState = GetCurrentState(group);
     if (currentState == state)
     {
         if (!useTransitions && (LayoutTransitionStoryboard != null))
         {
             StopAnimations();
         }
         return true;
     }
     SetCurrentState(group, state);
     Storyboard layoutStoryboard = ExtractLayoutStoryboard(state);
     List<OriginalLayoutValueRecord> originalLayoutValues = GetOriginalLayoutValues(group);
     if (originalLayoutValues == null)
     {
         originalLayoutValues = new List<OriginalLayoutValueRecord>();
         SetOriginalLayoutValues(group, originalLayoutValues);
     }
     if (!useTransitions)
     {
         if (LayoutTransitionStoryboard != null)
         {
             StopAnimations();
         }
         base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
         SetLayoutStoryboardProperties(control, templateRoot, layoutStoryboard, originalLayoutValues);
         return true;
     }
     if ((layoutStoryboard.Children.Count == 0) && (originalLayoutValues.Count == 0))
     {
         return base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
     }
     templateRoot.UpdateLayout();
     List<FrameworkElement> targets = FindTargetElements(control, templateRoot, layoutStoryboard, originalLayoutValues, MovingElements);
     Dictionary<FrameworkElement, Rect> rectsOfTargets = GetRectsOfTargets(targets, MovingElements);
     Dictionary<FrameworkElement, double> oldOpacities = GetOldOpacities(control, templateRoot, layoutStoryboard, originalLayoutValues, MovingElements);
     if (LayoutTransitionStoryboard != null)
     {
         templateRoot.LayoutUpdated -= ExtendedVisualStateManager.control_LayoutUpdated;
         StopAnimations();
         templateRoot.UpdateLayout();
     }
     base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
     SetLayoutStoryboardProperties(control, templateRoot, layoutStoryboard, originalLayoutValues);
     templateRoot.UpdateLayout();
     Dictionary<FrameworkElement, Rect> newRects = GetRectsOfTargets(targets, null);
     MovingElements = new List<FrameworkElement>();
     foreach (FrameworkElement element in targets)
     {
         if (rectsOfTargets[element] != newRects[element])
         {
             MovingElements.Add(element);
         }
     }
     foreach (FrameworkElement element2 in oldOpacities.Keys)
     {
         if (!MovingElements.Contains(element2))
         {
             MovingElements.Add(element2);
         }
     }
     WrapMovingElementsInCanvases(MovingElements, rectsOfTargets, newRects);
     VisualTransition transition = FindTransition(group, currentState, state);
     templateRoot.LayoutUpdated += ExtendedVisualStateManager.control_LayoutUpdated;
     LayoutTransitionStoryboard = CreateLayoutTransitionStoryboard(transition, MovingElements, oldOpacities);
     LayoutTransitionStoryboard.Completed += (sender, args) =>
     {
         templateRoot.LayoutUpdated -= ExtendedVisualStateManager.control_LayoutUpdated;
         StopAnimations();
     };
     LayoutTransitionStoryboard.Begin();
     return true;
 }
开发者ID:xperiandri,项目名称:Xaml.Interactions,代码行数:86,代码来源:ExtendedVisualStateManager.cs


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