예제 #1
0
 private static void ToggleIndeterminate(MetroProgressBar bar, bool oldValue, bool newValue)
 {
     if (bar != null && newValue != oldValue)
     {
         var indeterminateState = bar.GetIndeterminate();
         var containingObject = bar.GetTemplateChild("ContainingGrid") as FrameworkElement;
         if (indeterminateState != null && containingObject != null)
         {
             if (oldValue && indeterminateState.Storyboard != null)
             {
                 // remove the previous storyboard from the Grid #1855
                 indeterminateState.Storyboard.Stop(containingObject);
                 indeterminateState.Storyboard.Remove(containingObject);
             }
             if (newValue)
             {
                 var resetAction = new Action(() => {
                                                  bar.InvalidateMeasure();
                                                  bar.InvalidateArrange();
                                                  bar.ResetStoryboard(bar.ActualWidth, false);
                                              });
                 bar.Dispatcher.BeginInvoke(DispatcherPriority.Background, resetAction);
             }
         }
     }
 }
예제 #2
0
 private static void ToggleIndeterminate(MetroProgressBar bar, bool oldValue, bool newValue)
 {
     if (bar != null && newValue != oldValue)
     {
         VisualState      indeterminate = bar.GetIndeterminate();
         FrameworkElement templateChild = bar.GetTemplateChild("ContainingGrid") as FrameworkElement;
         if (indeterminate != null && templateChild != null)
         {
             if (oldValue && indeterminate.Storyboard != null)
             {
                 indeterminate.Storyboard.Stop(templateChild);
                 indeterminate.Storyboard.Remove(templateChild);
             }
             if (newValue)
             {
                 Action action = () => {
                     bar.InvalidateMeasure();
                     bar.InvalidateArrange();
                     bar.ResetStoryboard(bar.ActualWidth, false);
                 };
                 bar.Dispatcher.BeginInvoke(DispatcherPriority.Background, action);
             }
         }
     }
 }
예제 #3
0
 private static void ToggleIndeterminate(MetroProgressBar bar, bool oldValue, bool newValue)
 {
     if (bar != null && newValue != oldValue)
     {
         var indeterminateState = bar.GetIndeterminate();
         var containingObject   = bar.GetTemplateChild("ContainingGrid") as FrameworkElement;
         if (indeterminateState != null && containingObject != null)
         {
             if (oldValue && indeterminateState.Storyboard != null)
             {
                 // remove the previous storyboard from the Grid #1855
                 indeterminateState.Storyboard.Stop(containingObject);
                 indeterminateState.Storyboard.Remove(containingObject);
             }
             if (newValue)
             {
                 var resetAction = new Action(() => {
                     bar.InvalidateMeasure();
                     bar.InvalidateArrange();
                     bar.ResetStoryboard(bar.ActualWidth, false);
                 });
                 bar.Dispatcher.BeginInvoke(DispatcherPriority.Background, resetAction);
             }
         }
     }
 }