Dependency Property, wpf Dependency Property

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.