Dependency Property Uses in WPF -


I find it difficult to find good reasons for the dependency property, why the system Control. Text box "text" property is a dependency property and is not a common property? What are the advantages of this as a dependency asset?

One of the things I am trying to accomplish is to add a statutory rule which will include other validity rules for my UserControl. Here's how:

  & lt; Custom Control: Required Textbox Validity rule & gt; & Lt; Validators: NotNullOrEmptyValidationRule errormode = "first name may not be empty or empty" /> & Lt; / CustomControls: RequiredTextBox.ValidationRules & gt;  

The problem is I am not sure whether the validation rule should be property dependent property or just a general asset.

provides the above code the following error:

  { "Validation rules can not add elements; zero value of the property. WPFkValidationRules Learning Object" error ". NotNullOrEmptyValidationRule 'markup' Lrningvepif files, component / Adkastr Waindo. XML "line 35 position 66."}  

There is a wealth of validation rules:

  Public static read-only dependency Property validation ruleReference = Dependency Pro Rti. Registration ("Validation Rule", type (collection & lt; validation rule & gt;), type (required textbox), new frameworkprommetmatata (empty)); Public collection & lt; Validation Rules & gt; Validation Rule {Received {Return (Archiving & lt; Validation Rules & gt;) GetValue (Validation Rule Attribute); } Set {Set Value (Validation Rule Properties, Values); }}  

Profit is mainly two times:

Firstly A dependency asset is made only when it is used, this means that the text box class can be very efficient with low memory footprint because it has the actual properties that get the actual position on the heap. This is especially important in WPF where all the controls are more and more specific types of collections. If each of these internal types had to declare tens of properties to define behavior and then there would be a high level control like a button, then one hundred properties would end up with the size of a square with something in the ballpark.

The second dependency properties can be tied to an object that has been created for it. This allows a case where a control grid. Column can set property, which can be read and used for grid control layout. This means that we do not do hundreds of decorator classes that provide small pieces of essential functionality for other controls. This means that XML is very intuitive and readable.


To modify the example in your revised question, edit:

While your verification property will not get much profit from being a dependency property (basically the reasons in all the answers So far, I can only see my comments coming to play the memory footprint only), and this is definitely not profitable because it is in the case of property of text, where the text box is where you can bind it. Es, or it can change depending on any other input, I still can apply it as a dependency property would simplify my argument for it; You do not take much profit, but this also does not give you anything - I never thought that I had used a basic asset in custom control, whereas when I first started writing them, Attributes were upgrading to dependencies because I wanted some extra functionality

Simply put, while the dependency property is more complex to define that a normal property I still will use it as the actual standard for WPF control unless otherwise something to do Good reason was not standard for classrooms in the same way as a property, even if an area is easy to implement.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -