Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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". 
like image 720
Jan K. Avatar asked Apr 26 '26 02:04

Jan K.


1 Answers

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>
like image 66
sa_ddam213 Avatar answered Apr 28 '26 16:04

sa_ddam213