wpf在xaml里做动画(移动),如何设定相对已知值的From起始值
初学WPF,问题很初级的~~比如要做窗口移动的动画(上下),用代码可以这样:DoubleAnimationda1=newDoubleAnimation();da1.Fro...
初学WPF,问题很初级的~~
比如要做窗口移动的动画(上下),用代码可以这样:
DoubleAnimation da1 = new DoubleAnimation();
da1.From = this.Top + 10;
da1.To = this.Top;
this.BeginAnimation(Window.TopProperty, da1);
问题来了:在xaml里怎么写From和To?
<Storyboard x:Key="showWindow">
<DoubleAnimation Storyboard.TargetName="computerSelectWindow" Storyboard.TargetProperty="Top" From="这里怎么写" To="还有这里" />
</Storyboard> 展开
比如要做窗口移动的动画(上下),用代码可以这样:
DoubleAnimation da1 = new DoubleAnimation();
da1.From = this.Top + 10;
da1.To = this.Top;
this.BeginAnimation(Window.TopProperty, da1);
问题来了:在xaml里怎么写From和To?
<Storyboard x:Key="showWindow">
<DoubleAnimation Storyboard.TargetName="computerSelectWindow" Storyboard.TargetProperty="Top" From="这里怎么写" To="还有这里" />
</Storyboard> 展开
2个回答
展开全部
可以用绑定:
<Storyboard x:Key="showWindow">
<DoubleAnimation Storyboard.TargetName="computerSelectWindow" Storyboard.TargetProperty="Top" From="{Binding Top, ElementName=computerSelectWindow}" To="{Binding Top, Converter=abc, ElementName=computerSelectWindow}" />
</Storyboard>
其中Converter=abc中的abc是你需要Top+10的Converter
<Storyboard x:Key="showWindow">
<DoubleAnimation Storyboard.TargetName="computerSelectWindow" Storyboard.TargetProperty="Top" From="{Binding Top, ElementName=computerSelectWindow}" To="{Binding Top, Converter=abc, ElementName=computerSelectWindow}" />
</Storyboard>
其中Converter=abc中的abc是你需要Top+10的Converter
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询