开发者

Animate control in: use correct height

开发者 https://www.devze.com 2023-03-25 21:46 出处:网络
I have a Button and a UserControl. The height of the UserControl is set to 0. When I click the Button I use a StoryBoard to animate the height of the UserControl to 100. The UserControl becomes visibl

I have a Button and a UserControl. The height of the UserControl is set to 0. When I click the Button I use a StoryBoard to animate the height of the UserControl to 100. The UserControl becomes visible. Works fine.

But now I want to get rid of the fixed value of 100 and animate to the size that the UserControl would normally occupy. Any suggestions on how to do this?

Here's my StoryBoard.

<Storyboard x:Key="animateIn">
    <DoubleAnimation To="100" Storyboard.TargetName="myControl" 开发者_如何学JAVAStoryboard.TargetProperty="Height" Duration="0:0:0.1" />
</Storyboard>


Animate ScaleTransform.ScaleY instead.

<UserControl x:Name="myControl">
    <UserControl.LayoutTransform>
        <ScaleTransform ScaleY="0" />
    </UserControl.LayoutTransform>
</UserControl>

<Storyboard x:Key="animateIn">
    <DoubleAnimation To="1"
        Storyboard.TargetName="myControl"
        Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)"
        Duration="0:0:0.1" />
</Storyboard>
0

精彩评论

暂无评论...
验证码 换一张
取 消