Jan K.
Jan K.

Reputation: 2582

Animate RenderTransformOrigin

I would like to modify RenderTransformOriginin a xaml storyboard. The value must not be animated, a immediately change would be also fine. The following code dosn't work:

<Storyboard x:Key="StoryboardFadeIn">
  <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransformOrigin).(Point.X)" Storyboard.TargetName="UserControl" To="0"/>
  <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransformOrigin).(Point.Y)" Storyboard.TargetName="UserControl" To="0"/>
</Storyboard>

Is it possible to change this property in an animation (using only xaml)?

Errorcode:

The property "X" is not a DependencyProperty. To be used in markup, non-attached properties must be exposed on the target type with an accessible instance property "X". 

Upvotes: 3

Views: 1220

Answers (1)

sa_ddam213
sa_ddam213

Reputation: 43596

I'm not sure if you can Animate the X and Y of a point structure using DoubleAnimation, but you should be able to animate the RenderTransformOrigin using a PointAnimation

Example:

<Storyboard x:Key="StoryboardFadeIn">
    <PointAnimation Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="UserControl" To="0,0"/>
</Storyboard>

Upvotes: 7

Related Questions