Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is the animation method, it is called from the
- // SelectionChanged handler in the behavior passing the
- // AssociatedObject as the ComboBox parameter.
- public void AnimateComboBox(ComboBox cbo)
- {
- LinearGradientBrush myBrush = new LinearGradientBrush();
- myBrush = (cbo.BorderBrush as LinearGradientBrush);
- Storyboard sb = new Storyboard();
- sb.Duration = new Duration(TimeSpan.FromMilliseconds(3000));
- //have to animate each gradient stop
- foreach(GradientStop s in myBrush.GradientStops)
- {
- ColorAnimation anim = new ColorAnimation();
- anim.To = Colors.Red;
- anim.Duration = new Duration(TimeSpan.FromSeconds(0.5));
- //auto-reverse and repeat for pulsation
- anim.AutoReverse = true;
- anim.RepeatBehavior = RepeatBehavior.Forever;
- Storyboard.SetTarget(anim, s);
- Storyboard.SetTargetProperty(anim,
- new PropertyPath(GradientStop.ColorProperty));
- sb.Children.Add(anim);
- }
- sb.Begin();
- }
- <ComboBox > <!-- leaving out ItemsSource and so-forth for brevity -->
- <i:Interaction.Behaviors>
- <vms:AnimateSelectionChangedBehavior/>
- </i:Interaction.Behaviors>
- </ComboBox>
- <ComboBox>
- <!-- this one does not have the behavior, but its border
- changes with the other one. -->
- </ComboBox>
Add Comment
Please, Sign In to add comment