當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。