你可以使用一个DynamicResource在包含的样式或控件模板一个Storyboard [英] Can You Use A DynamicResource in a Storyboard Contained Within Style Or ControlTemplate

查看:183
本文介绍了你可以使用一个DynamicResource在包含的样式或控件模板一个Storyboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用包含在控件模板内的故事板一个DynamicResource。

I am trying to use a DynamicResource in Storyboard contained within a ControlTemplate.

但是,当我尝试这样做,我得到一个不能冻结这个故事板时间表树跨线程使用的错误。

But, when I try to do this, I get a 'Cannot freeze this Storyboard timeline tree for use across threads' error.

这是怎么回事呢?

推荐答案

没有,你不能在包含样式或控件模板中的故事板使用DynamicResource。事实上,你不能使用数据绑定任前pression。

No, you can't use a DynamicResource in a Storyboard that is contained within a Style or ControlTemplate. In fact, you can't use a data binding expression either.

下面的故事是一个样式或控件模板内的所有内容必须是跨线程使用和计时系统实际上是尝试冻结样式或控件模板,使他们线程安全的安全。然而,如果一个DynamicResource或数据绑定前pression是present,它无法冷冻。

The story here is that everything within a Style or ControlTemplate must be safe for use across threads and the timing system actually tries to freeze the Style or ControlTemplate to make them thread-safe. However, if a DynamicResource or data binding expression is present, it is unable to freeze them.

有关更多信息,请参阅: MSDN链接。退房在动画样式和动画中的ControlTemplate'部分(此文档页面比较长)。

For more info see: MSDN Link. Check out the 'Animate in a Style' and the 'Animate in a ControlTemplate' sections (this documentation page is rather long).

和一个变通方法(至少对我的情况)请参见:<一href=\"http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9336022f-badb-4b40-a86c-a50ab1a64ba5/\">WPF论坛帖子。

And for a workaround (at least for my scenario) see: WPF Forum Post.

希望这可以帮助别人。我已经失去了足够多的头发就可以了。

Hope this helps someone. I've lost more than enough hair on it.

科里斯

这篇关于你可以使用一个DynamicResource在包含的样式或控件模板一个Storyboard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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