wpf - Constraint to limit the scope of an attached dependency property -


Is an attached dependency a way to add an obstacle to the property so that it can only be applied to a specific type, something In Metadata?

If not, then is it clearly useful for the stable gate-and-set of attached DPs?

Example:

If I have the following declaration for example:

  Public Fixed Intake Attack (Dependent Object OBJ) {Return (int) obj.GetValue (AttachedIntproperty); } Public static zero SetAttachedInt (dependency object obj, int value) {obj.SetValue (AttachedIntProperty, value); } Dependency for public static reading Attachment Property = Dependency Property. Registrant (attachment "attachment", typef (int), typef (masters squad), new utoppromatatata (0));  

Would it be meaningful to change it only to apply it to the textbox?

  Public Static Ent-AttachmentInt (Textbox Text Box) {Return (int) textBox.GetValue (AttachedIntProperty); } Public static zero SetAttachedInt (text box text box, int value) {textBox.SetValue (attachmentIntproperty, value); } Dependency for public static reading Attachment Property = Dependency Property. Registrant (attachment "attachment", typef (int), typef (masters squad), new utoppromatatata (0));  

My question is because it leads to an inconsistency, because there is no possibility of using gatewalls and set-value for any type and limiting attachments in markup.

What did I do before that I added an exception to the handler in the property and raised an exception there only the type xy allowed.

What do you think?

I believe that you have to limit all the target types of attributes Need GetPropertyName and SetPropertyName methods.

Example:

  Public static int GetAttachedInt (MyTargetType obj) {Return (int) obj.GetValue (AttachedIntProperty); } Public Fixed Zero SetAttachedInt (MyTargetType obj, int value) {obj.SetValue (AttachedIntProperty, Value); }  

Where MyTargetType DependencyObject can be any type inheriting.


Comments