如何从离散&QUOT动画GridLength;自动"到" * QUOT ;? [英] How to discrete animate GridLength from "Auto" to "*"?

查看:187
本文介绍了如何从离散&QUOT动画GridLength;自动"到" * QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用故事板动画此属性。
正在写自己的动画是一个最好的选择?

I need to animate this property using a Storyboard. Is writing your own animation is a best choice?

推荐答案

没有,它使用标准的XAML是完全可能的:

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>

和更容易回自动:

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

这篇关于如何从离散&QUOT动画GridLength;自动&QUOT;到&QUOT; * QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆