如何在 WPF 故事板中为静态对象添加动画效果
我有一个 WPF 程序,需要添加“演示模式”。 由于我希望我的设计人员能够修改演示模式,而不必每次都重新编译程序,因此我认为使用外部 XAML 文件中的故事板是个好主意。 “演示模式”基本上是一个故事板,动画应用程序的一些依赖属性。
为了公开我的应用程序的 DP,我创建了应用程序类的公共静态成员(单例),以便应用程序的 DP 始终在外部可用。 在这种情况下,故事板将访问它们。
在外部 XAML 文件中,我添加了正确引用应用程序的命名空间/程序集的正确 xmlns。 因此理论上,我应该能够在 Storyboard 中访问应用程序的 DP。
问题是,当 XAML 中未声明/命名对象时,我不知道如何为 Storyboard 中的静态对象的 DP 制作动画。 声明故事板动画帧时,唯一的故事板附加属性是 Storyboard.TargetName 和 Storyboard.TargetProperty。
如果有人能给我一个提示,让我朝着正确的方向前进,我将不胜感激。
I have a WPF program to which I need to add a "Demo mode". Since I want my designers to be able to modify the demo mode without me having to recompile the program each time, I tough it would be a great idea to use a storyboard from an external XAML file. The "Demo mode" is basically a storyboard animating some of the application's dependency properties.
To expose my application's DPs, I have created a public static member (singleton) of the application's class so that the application's DPs are always available externally. In this case, the storyboard will be accessing them.
In the external XAML file, I have added the proper xmlns referencing correctly the application's namespace/assembly. So in theory, I should be able to access the application's DP in a Storyboard.
The problem is that I don't know how to animate a DP of a static object in a Storyboard when the object is not declared/named in the XAML. When declaring a storyboard animation frame, the only storyboard's attached property are Storyboard.TargetName and Storyboard.TargetProperty.
I would appreciate if someone could give me a hint to get me in the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有尝试过,但如果可行的话,我猜它看起来像这样:
I haven't tried this out, but if it is doable I would guess it looks something like this: