WPF的Silverlight港口故事板
试图从旧的Silverlight应用程序中移植一些行为,该应用程序允许用户通过移动/最小化/最大化各种UserControls来配置其视图。在UserControl.Resources中宣布了几个故事板,然后通过X:名称从代码访问。
<Storyboard x:Name="MaximizeStoryboard" Completed="MaximizeStoryboard_Completed" Storyboard.TargetName="WholeControl">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame x:Name="MaximizeWidth" KeyTime="00:00:00.3000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
...
在WPF中,在更改x:name x:key之后,我可以通过:
Storyboard maximizeStoryboard = (Storyboard)Resources["MaximizeStoryboard"];
先前用于
MaximizeWidth.Value = Container.Contents.ActualWidth;
在开始动画之前从代码设置还原宽度(和其他值)。这在WPF中不起作用。可以从代码设置这些值的正确方法是什么?
Trying to port to WPF some behavior from an old Silverlight application that allowed users to configure their view by moving/minimizing/maximizing various UserControls. Several StoryBoards were declared in UserControl.Resources and later accessed from code via their x:Name.
<Storyboard x:Name="MaximizeStoryboard" Completed="MaximizeStoryboard_Completed" Storyboard.TargetName="WholeControl">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame x:Name="MaximizeWidth" KeyTime="00:00:00.3000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
...
In WPF, after changing x:Name to x:Key, I can access the Storyboard via:
Storyboard maximizeStoryboard = (Storyboard)Resources["MaximizeStoryboard"];
Previously used
MaximizeWidth.Value = Container.Contents.ActualWidth;
to set the restore width (and other values) from code, before beginning the animation. That doesn't work in WPF. What is the proper way to get access so those values can be set from code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以通过
Storyboard
的孩子进行的一种可能的方法,查找doubleAnimationusingKeyframes
孩子,然后获得第一个keyframe
。One of the possible way can be go through the children of
Storyboard
, findDoubleAnimationUsingKeyFrames
child and then get the firstKeyFrame
.