I am animating a border resize in Silverlight however I also need to gradually remove the margin around it (currently 50). Blend doesn't seem to generate a tween for margin change - it just jumps from 50 to 0 in one go. Is there a way to achieve this?
相关问题
- how to Enumerate local fonts in silverlight 4
- Free Silverlight mapping with Bing maps and OpenSt
- Custom number picker?
- Animate a WPF Window left and right with a shake e
- Error using ResourceDictionary in Silverlight
相关文章
- “Storyboard.storyboard” could not be opened
- Keep constant number of visible circles in 3D anim
- Animate opacity on hover (jQuery)
- New Windows Application - What language?
- Swift - Outlets cannot be connected to repeating c
- relative url in wcf service binding
- Embedded images not showing when in a UserControl
- How to set the image resolution for animations?
Here is an updated version that allows you to animate from within XAML
And then you can do this in XAML
Note that if you don't set a Target property to a DoubleAnimation in XAML, you won't be able to display the control/page in Blend. To fix this, just add a fake target property (in the code above I added the opacity property which is a double value), And it will be overriden at runtime anyway
The problem is that a Margin is really of type "System.Windows.Thickness" which is NOT a dependency object, thus Left, Top, Right, and Bottom are NOT Dependency Properties and thus cannot be animated using DoubleAnimation (which allows for tweening).
What is used to animate the Margin is an ObjectAnimation which does not tween. This is why you see the margin jump from its original location to its new location. As another common example, the same happens when you try to animate the Visibility property between Visible and Collapsed.
You would either need to do timer based animation in order to animate margin or implement your own Animation type for Thickness objects.
Ben Lemmon gives an elegant solution: http://blogs.msdn.com/blemmon/archive/2009/03/18/animating-margins-in-silverlight.aspx