[WPF/Silverlight] differences between CLR property and WPF Dependency Property

Source: Internet
Author: User

Generally, there are n different methods to implement certain functions under the. NET Framework. Using "property" is one of them. You can use both CLR property and Dependency Property.

If you are not familiar with these two things, let's briefly introduce them. Let's take a look at the most frequently used CLR property in. Net:

Public String authorname {Get; set ;}

Familiar with zookeeper?

Dependency properties was a concept proposed in WPF a few years ago and was later extended to Silverlight (WPF/E ).

Public static readonly dependencyproperty authornameproperty = dependencyproperty. Register ("authorname", typeof (string), typeof (PAGE), new propertymetadata (""));

CLR porperty is obviously more easy to understand, at least it is easier to remember. In contrast, even for a WPF or Silverlight veteran, it is much more troublesome to learn to declare a dependencyproperty.

However, dependencyproperty provides more functions than the traditional CLR property. It can set attributes for an animation, Data Association, and resource storage. For more information, see this article.

We can observe the differences between the two attributes through the "generate attribute" function in blend to give a rough understanding of them. For example, when a CLR property is generated:

, Many Command Options are grayed out. Let's take a look at Dependency Property

It not only retains all the functions of CLR property, but also adds support for converting to resources and data association. Of course, it is quite easy to operate an animation.

 

Stand up and applaud!

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.