示例#1
0
 private void CheckBox_Checked(object sender, RoutedEventArgs e)
 {
     if (AnimatedTextBlock != null)
     {
         if (((CheckBox)sender).IsChecked == true)
         {
             AnimatedTextBlock.RepeatBehavior = RepeatBehavior.Forever;
         }
         else
         {
             AnimatedTextBlock.ClearValue(AnimatedTextBlock.RepeatBehaviorProperty);
         }
     }
 }
        private void AdjustWidth()
        {
            AnimatedTextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            double           textWidth    = AnimatedTextBlock.DesiredSize.Width;
            double           widthToBeSet = AnimatedTextBlock.ActualWidth;
            FrameworkElement parent       = Parent as FrameworkElement;

            if (parent != null)
            {
                widthToBeSet = parent.ActualWidth < AnimatedTextBlock.ActualWidth ? AnimatedTextBlock.ActualWidth : parent.ActualWidth;
                MarqueeStoryboard.Stop();
                AdjustAnimationDuration();
                Width = widthToBeSet;
                MarqueeAnimation.To   = -AnimatedTextBlock.DesiredSize.Width;
                MarqueeAnimation.From = parent.ActualWidth == 0 ? KOutOfTheScreenWidth : parent.ActualWidth; // Workaround: To avoid flicker on screen show up
                MarqueeStoryboard.Begin();
            }
        }
示例#3
0
    public static void TriggerThisEvent(this RoutedEvent routedEvt, AnimatedTextBlock tb)
    {
        RoutedEventArgs args = new RoutedEventArgs(AnimatedTextBlock.MyCustomEvent, tb);

        tb.RaiseEvent(args);
    }