为什么 Silverlight 4 中不鼓励使用触发器?
Silverlight 的 MSDN 文档现在在多个地方进行了说明:
不过,Expression Blend 似乎很乐意支持和鼓励它们的使用,并且有很多博客文章赞扬了触发器和操作的使用,没有任何警告。
推荐的触发器替代品是什么?我应该坚持使用代码隐藏事件处理程序吗?
The MSDN documentation for Silverlight now states in several places:
The entire Triggers syntax is a discouraged technique in Silverlight 4. [1, 2]
Expression Blend seems to happily support and encourage their use, though, and there are plenty of blog posts extolling the use of Triggers and Actions without any caveats.
What is the recommended replacement for triggers? Should I stick to code-behind event handlers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你会混淆两个不同的触发器。您指向的MSDN文档是Silverlight SDK
System.Windows
触发器,除了支持Loaded事件之外什么也做不了。您在博客文章中看到的大量触发器和操作都引用了 Blend SDK,它们具有更广泛的范围并且非常有用。
Your get mixed up between two different Triggers. The MSDN documentation you point to are Silverlight SDK
System.Windows
triggers that apart from supporting the Loaded event can do nothing else.The plethora of Triggers and Actions you are seeing in blog posts refer the Blend SDK which have a much wider scope and are very useful.
在 Silverlight 中,他们引入了 VisualStateManager,这被视为实现触发器通常用途的更简洁的方法。它很受欢迎并且(我认为)此后已被添加到 WPF 中。
Tim Heuer 的博客对使用 VSM 有相当好的介绍:
http://timheuer.com/blog/archive/2008/06/04/silverlight-introduces-visual-state-manager-vsm.aspx
In Silverlight they introduced the VisualStateManager which is seen as a cleaner way of achieving what Triggers are normally used for. It was well received and (I think) has since been added to WPF.
Tim Heuer's blog has a fairly good introduction to using the VSM:
http://timheuer.com/blog/archive/2008/06/04/silverlight-introduces-visual-state-manager-vsm.aspx