开发者

How to discrete animate GridLength from "Auto" to "*"?

开发者 https://www.devze.com 2022-12-19 15:46 出处:网络
I need to animate this property using开发者_开发百科 a Storyboard. Is writing your own animation is a best choice?No, it is quite possible using the standard XAML:

I need to animate this property using开发者_开发百科 a Storyboard. Is writing your own animation is a best choice?


No, it is quite possible using the standard XAML:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" x:Name="col0"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.Resources>
        <Storyboard x:Key="sbCol0ToAuto">
            <ObjectAnimationUsingKeyFrames 
                BeginTime="0" Duration="0"
                Storyboard.TargetName="col0" Storyboard.TargetProperty="Width">
                <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                        <GridLength>*</GridLength>
                     </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
             </ObjectAnimationUsingKeyFrames>
         </Storyboard>
    </Grid.Resources>
...
</Grid>

And even easier back to Auto:

<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static GridLength.Auto}">
0

精彩评论

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