Animatable.GetAnimationBaseValue Method
.NET Framework 4
Returns the non-animated value of the specified DependencyProperty.
Assembly: PresentationCore (in PresentationCore.dll)
Parameters
- dp
- Type: System.Windows.DependencyProperty
Identifies the property whose base (non-animated) value should be retrieved.
Return Value
Type: System.ObjectThe value that would be returned if the specified property were not animated.
Implements
IAnimatable.GetAnimationBaseValue(DependencyProperty)In the following example, the non-animated values of animated properties are retrieved and displayed.
/* This sample shows how to use the Animatable.GetAnimationBaseValue and UIElement.GetAnimationBaseValue methods to get the non-animated value of an animated Animatable or UIElement. */ using System; using System.Windows; using System.Windows.Navigation; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Controls; using System.Windows.Input; namespace Microsoft.Samples.Animation.TimingBehaviors { public class GetAnimationBaseValueExample : Page { private RotateTransform animatedRotateTransform; public GetAnimationBaseValueExample() { WindowTitle = "GetAnimationBaseValue Example"; StackPanel myPanel = new StackPanel(); myPanel.Margin = new Thickness(20.0); // Create a button. Button animatedButton = new Button(); animatedButton.Content = "Click Me"; animatedButton.Width = 100; animatedButton.Margin = new Thickness(100); // Create and animate a RotateTransform and // apply it to the button's RenderTransform // property. animatedRotateTransform = new RotateTransform(); animatedRotateTransform.Angle = 45; DoubleAnimation angleAnimation = new DoubleAnimation(0,360, TimeSpan.FromSeconds(5)); angleAnimation.RepeatBehavior = RepeatBehavior.Forever; animatedRotateTransform.BeginAnimation( RotateTransform.AngleProperty, angleAnimation); animatedButton.RenderTransform = animatedRotateTransform; animatedButton.RenderTransformOrigin = new Point(0.5,0.5); // Animate the button's width. DoubleAnimation widthAnimation = new DoubleAnimation(120, 300, TimeSpan.FromSeconds(5)); widthAnimation.RepeatBehavior = RepeatBehavior.Forever; widthAnimation.AutoReverse = true; animatedButton.BeginAnimation(Button.WidthProperty, widthAnimation); // Handle button clicks. animatedButton.Click += new RoutedEventHandler(animatedButton_Clicked); // Add the button to the panel. myPanel.Children.Add(animatedButton); this.Content = myPanel; } // Display the base value for Button.Width and RotateTransform.Angle. private void animatedButton_Clicked(object sender, RoutedEventArgs e) { Button animatedButton = (Button)sender; MessageBox.Show("Button width base value: " + animatedButton.GetAnimationBaseValue(Button.WidthProperty) + "\nRotateTransform base value: " + animatedRotateTransform.GetAnimationBaseValue(RotateTransform.AngleProperty)); } } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.