Dependency Property, wpf Dependency Property
Q: When will DP be used?
A: When you need to support style, data binding, animation, Blend designer, etc.
Q: What are the key points of difference between DP and CLR attributes?
A: Static, GetValue/SetValue (DependencyObject), Dependency, time for Space
Q: What is the priority of the DP value?
A: Property System forced conversion> animation> local value> trigger> Setter> inherit> default value of Dependency Property metadata
Q: What are the advantages of DP?
A: inheritance, reduce memory usage, change notification
Demo
The difference between wpf dependency attributes and static attributes
First, let's talk about common attributes. Each instance has a backup in memory. A static attribute has only one class. No matter how many instances there are, there is only one static attribute with the same value. There is only one backup in the application domain. The dependency attributes are different. Only when the dependency attribute of an instance is assigned a value, this attribute of the instance is backed up in the memory. For example, you have 1000 yuan, which is stored in a bank. It does not belong to you, but it still belongs to you, not to the bank or other people.
The difference between wpf dependency attributes and static attributes
First, let's talk about common attributes. Each instance has a backup in memory. A static attribute has only one class. No matter how many instances there are, there is only one static attribute with the same value. There is only one backup in the application domain. The dependency attributes are different. Only when the dependency attribute of an instance is assigned a value, this attribute of the instance is backed up in the memory. For example, you have 1000 yuan, which is stored in a bank. It does not belong to you, but it still belongs to you, not to the bank or other people.