附加属性的各种用途是什么? [英] What are the various uses of Attached Properties?

查看:35
本文介绍了附加属性的各种用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经在 WPF 中看到了一些非常不同的 AttachedProperties 用途,我想知道,有哪些不同的用途?

I've seen some really varying uses of AttachedProperties so far in my adventures in WPF, and am wondering, what are some of the various uses?

我见过相当普通的用途,例如在 Grid 和 Canvas 中发现的用途,以及一些非常酷的 hacks,允许在没有 setter 的情况下绑定到集合.您为 AttachedProperties 找到了哪些其他应用程序?(代码示例真的很有帮助!)

I've seen fairly mundane uses, such as those found in Grid and Canvas, as well as some really cool hacks allowing binding to collections without setters. What other applications have you found for AttachedProperties? (Code samples really helpful!)

推荐答案

查看附加的行为.

http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx//不确定此链接的质量.我在谷歌上搜索后找到的第一个.

http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx //not sure on the quality of this link. First one I came to after googling.

将行为附加到对象只是意味着让对象做它不会做的事情自己的

Attaching a behavior to an object simply means making the object do something that it would not do on its own

通过附加行为实际上可以做的事情的可能性是无限的,但它通常可以减少扩展控件或向后面的代码添加逻辑的需要.

The possibilities are pretty limitless on what you can actually do through attached behaviours but it can often reduce the need to extend controls or add logic to a code behind.

这篇关于附加属性的各种用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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