5

I have created a user control:

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

What I want to achieve is that when IsActive property of the user control's view model class is set to true, the zoomIn animation is run. This animation is supposed to zoom in the grid with it's content inside. When I trigger the animation, I get the following error message:

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

What is wrong with my animation? How should I implement the described zoom in animation? Thanks.

1 Answer 1

3

I got it:

  • <ScaleTransform> should have <ScaleTransform ScaleX="0.5" ScaleY="0.5" /> properties set in order to make the zoom start from 50%, for example.
  • In the first <DoubleAnimation> the value of the Storyboard.TargetProperty property should be changed from "ScaleTransform.ScaleX" to "RenderTransform.ScaleX".
  • In the second <DoubleAnimation> the value of the Storyboard.TargetProperty property should be changed from "ScaleTransform.ScaleY" to "RenderTransform.ScaleY".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.