什么是依赖属性以及为什么我们在wpf中使用它以及为什么它总是静态只读 [英] what is dependency property and why we are using that in wpf and why it is always static readonly

查看:116
本文介绍了什么是依赖属性以及为什么我们在wpf中使用它以及为什么它总是静态只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我有关依赖属性的事情。

提前谢谢

Can anyone tell me clearly about dependency property.
Thanks in advance

推荐答案

好吧,你吞下了纯粹的术语诱饵,如果您认为依赖属性始终是静态只读。差远了。 Always static不是属性(当然可以是静态的),但类 StaticProperty 的实例,这是 - 惊喜! - 不是财产。 (因此,只读属性只是你的幻想。)



这是一个实现属性所需的静态字段,一种属性描述符,它是一个真正的.NET属性,当然,不必是静态的。



您可以阅读原始文档并理解所有内容:https://msdn.microsoft.com/en-us/library/ms752914%28v=vs .110%29.aspx



当然,它需要使用你大脑的肌肉。如果您认为这很困难,我可以为您提供非常简化,极简短的解释,包括使用此功能的想法和技术,解释基本原理,以及尽可能短的代码示例。请参阅我的文章的这一部分: 不需要的WPF ProgressBar动画问题:更清晰的解决方案(3.3。依赖属性的美德)



文章本身非常微不足道,专注于一个小问题,但依赖属性功能的插图是非常清晰和简约的。当然,我的解释并不全面。有关所有细节,请参阅第一个链接。



-SA
All right, you swallowed the pure terminological bait, if you think that dependency property "is always static readonly". Not even close. "Always static" is not a property (which is of course can be static), but the instance of the class StaticProperty, which is — surprise! — is not a property. (Therefore, "readonly property" is just your fantasy.)

This is a static field needed to implement the property, a kind of a property descriptor, which is a real .NET property and, of course, does not have to be static.

You can read original documentation and understand it all: https://msdn.microsoft.com/en-us/library/ms752914%28v=vs.110%29.aspx.

Of course, it requires using your brain's muscles. If you think it's difficult, I can offer you very simplified, extremely short explanation of the idea and the technique of using of this feature, with explanation of the rationale, complete with a shortest possible code sample. Please see just this section of my article: The Problem of Unwanted WPF ProgressBar Animation: a Clearer Solution (3.3. By Virtue of Dependency Property).

The article itself is very insignificant, dedicated to a tiny problem, but the illustration of the dependency property feature is really clear and minimalistic. Of course, my explanation is not comprehensive. For all the detail, please see the first link.

—SA


这篇关于什么是依赖属性以及为什么我们在wpf中使用它以及为什么它总是静态只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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