Page 1 of 1

Animating model properties

Posted: 19 Jun 2023, 07:53
by mshvern23
I have a CameraOffset value on my model. I can change it just fine using
<b:ChangePropertyAction TargetObject="{Binding}" PropertyName="CameraOffset" Value="300,100"/>
But a storyboard defined like this would not work
<PointAnimationUsingKeyFrames Storyboard.Target="{Binding}" Storyboard.TargetProperty="CameraOffset">
Is there a way to make storyboard animations for model properties?

I tried all sorts of variations, most result in something like this
LogNoesis: Error: Binding failed: Path=Self, Source=NoesisGUI.GameMapView(''), Target=PointAnimationUsingKeyFrames(''), TargetProperty=Storyboard.Target

Re: Animating model properties

Posted: 20 Jun 2023, 19:02
by sfernandez
Yes, only dependency properties can be animated. So you can bind your model property to a UI element property with a TwoWay binding. Then you can animate the UI element property, and the animated value will be transferred to the model.

Could something like this work for you?
<Decorator x:Name="test" RenderTransformOrigin="{Binding CameraOffset, Mode=TwoWay}"/>

Re: Animating model properties

Posted: 22 Jun 2023, 01:07
by mshvern23
Thanks, I think this is a decent workaround to not have to declare a dependency property