WPF Dependency Object -


has ever heard of implementing idependencyobject instead of inheriting -- way 1 create class hierarchy instead of having use interfaces when trying both dependency object/property , custom behavior on our classes.

i want have hierarchy of class kinds directly usable in context of existing structure, i.e. polygon. want able use polytype in place, , without more dialogue , indirection required if place polygon existing type part of dependencyobject. want able have class a) target of {binding} markup extension, b) animate properties of polytype , c) apply themed styling polytype.

i want implement idependencyobject instead of being forced inherit directly, , obstructing ability direct descendent , usable in place of, polygon.

not sure why have inherit dependencyobject. use custom code snippet generates following code register dependancy property:

public partial class usercontrol1 : usercontrol { public static dependencyproperty mypropertyproperty = dependencyproperty.register("myproperty", typeof(polygon), typeof(usercontrol1), new frameworkpropertymetadata(new propertychangedcallback(myproperty_changed)));  public polygon myproperty {     { return (polygon)getvalue(mypropertyproperty); }     set { setvalue(mypropertyproperty, value); } }   private static void myproperty_changed(dependencyobject o, dependencypropertychangedeventargs args) {     usercontrol1 thisclass = (usercontrol1)o;     thisclass.setmyproperty(); }  private void setmyproperty() {     //put instance myproperty property changed code here }   public usercontrol1() {     initializecomponent(); } 

}

as can see dependencyobject can type of object. if not need, please post code examples, or explain situation better.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -