WPF:缩放用户控制动画

我创建了一个用户控件:

<UserControl ...>
  <Grid DataContext="{Binding UserContrlViewModel>
    <Grid Width="200" Height="100" RenderTransformOrigin="0.5,0.5">
      <Grid.Resources>
        <Storyboard x:Key="zoomIn">
          <DoubleAnimation 
              Storyboard.TargetProperty="ScaleTransform.ScaleX" 
              From="0" 
              To="1" 
              Duration="0:0:1" /> 
          <DoubleAnimation 
              Storyboard.TargetProperty="ScaleTransform.ScaleY" 
              From="0"        
              To="1" 
              Duration="0:0:1" />
        </Storyboard>
      </Grid.Resources>
      <Grid.RenderTransform>
        <ScaleTransform />
      </Grid.RenderTransform>
      <Grid.Style>
        <Style TargetType="Grid">
          <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsActive}" Value="True">
              <DataTrigger.EnterActions>
                <BeginStoryboard>
                  <StaticResource ResourceKey="zoomIn" />
                </BeginStoryboard>
              </DataTrigger.EnterActions>
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Grid.Style>

      <TextBlock Width="60" Text="Input" />
      <TextBox Width="80" Margin="80,0,0,0" />

    </Grid>
    ...
  </Grid>
</UserControl>

我想要实现的是当用户控件的视图模型类的IsActive属性设置为true时,运行zoomIn动画.这个动画应该放大网格里面的内容.当我触发动画时,我收到以下错误消息:

Cannot resolve all property references in the property path ‘ScaleTransform.ScaleX’. Verify that applicable objects support the properties.

我的动画有什么问题?我该如何实现所描述的放大动画?谢谢.

最佳答案 我知道了:

>< ScaleTransform>应该具有< ScaleTransform ScaleX =“0.5”ScaleY =“0.5”/>性能
例如,设置为使缩放从50%开始.
>在第一个< DoubleAnimation>中Storyboard.TargetProperty属性的值
应该从“ScaleTransform.ScaleX”更改为“RenderTransform.ScaleX”.
>在第二个< DoubleAnimation> Storyboard.TargetProperty属性的值
应该从“ScaleTransform.ScaleY”更改为“RenderTransform.ScaleY”.

点赞