Animate RenderTransformOrigin

时间:2013-04-24 09:46:20

标签: c# wpf xaml animation

我想在xaml RenderTransformOrigin中修改storyboard。该值不能动画,立即更改也可以。 以下代码不起作用:

<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>

是否可以在动画中更改此属性(仅使用xaml)?

错误码:

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". 

1 个答案:

答案 0 :(得分:6)

我不确定您是否可以使用X为点结构的YDoubleAnimation设置动画,但您应该能够使用RenderTransformOriginPointAnimation设置动画。 <Storyboard x:Key="StoryboardFadeIn"> <PointAnimation Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="UserControl" To="0,0"/> </Storyboard>

示例:

{{1}}