views:

251

answers:

2

Hi all!

Can DoubleAnimations be applied to any double? Or just some?

In WPF, I know you can create a DoubleAnimation object:

var ani = new DoubleAnimation();

..and that object can be used in the BeginAnimation method of UIElements.

In my case, however, I'd like to just apply the animation to the object the the UIElement is bound to. I have a ListBox whose ItemsPanel has been set to be a Canvas, and the ListBoxItems use a converter to set the Canvas.Left and .Top properties, based on the property (call it

public Point Location {get; set; } // this is a lie for brevity; I'm actually raising OnPropertyChanged

)

So I'd like to apply an animation object to Location.X and Location.Y. Can DoubleAnimations be applied to any double? Or just some?

The learning never ends...

Edit #1: I'm being told only dependancy properties. As I suspected. This begs the question, How can the Location property I mentioned be made a dependancy property, so that I can animate ListBoxItems on a canvas?

+1  A: 

Only DependencyPropertys. As per MSDN:

Dependency properties provide support for value expressions, property invalidation and dependent-value coercion, default values, inheritance, data binding, animation, property change notification, and styling.

EDIT: If you want to animate a Point, use PointAnimation.

HTH, Kent

Kent Boogaart
Please see comment. Tricky stuff, I think.
Take a look at this page to create custom dependency properties: http://msdn.microsoft.com/en-us/library/ms753358.aspx
siz
A: 

It can only be applied on dependency properties

Thomas Levesque