我正在尝试做一个翻译转换动画片。在动画中,我需要我的对象保留在窗口的中心。我知道 WPF 动画是 Freezable 的。我正在使用转换器,但它会在启动时初始化值。有没有办法设置的值缓动双关键帧在运行时?
这是我的 XAML 代码:
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding Width, Converter={StaticResource Minus}, ElementName=grid}"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Width, Converter={StaticResource EnteringValueConverter}, ElementName=grid}"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
将 x:Name 属性添加到 EasingDoubleKeyFrame 元素。
之后您应该能够通过代码访问它:
x:名称=“关键帧”
Then:
keyframe.SetValue(EasingDoubleKeyFrame.ValueProperty, yourValue);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)