Firing events upon changes to a FrameworkElement


okay, here situation:

in app building, have lot of "adorning controls".  clarify means, there things "resize adorner".  when object comes focus in app, resize handles appear , give user option resize object.  resize adorner.  there other kinds of adorners have built well.

i decided consolidate adorners , make them inherit 1 base adorner class created.  adorner class holds reference adornedelement.....the thing adorner adorning.  adornedelement frameworkelement.  basically, long adorner inherits base adorner class, can accept frameworkelement thing adorn.

i have created event call adornedelementchanged, , wanting fire event any time in adornedelement gets changed (whether entire object or property of object...such width or height).  have not found way this.  far have fire event myself anytime of classes change adornerelement.  example, lets have resize adorner.  in class might this:

 public void resizeadornedelement ( double newheight, double newwidth )
{
    adornedelement.height = newheight;
    adornedelement.width = newwidth;
    
    //fire event notifying adorned element has been changed
    adornedelementchangedeventargs e = new adornedelementchangedeventargs();
    notifyadornedelementchanged(e);
}

 

some of might say: "put call notifyadornedelementchanged in setter."  nope.  doesn't work.  setter applies when entire frameworkelement set new.....but not when specific property of set.

others of might say: "use dependencyproperty , give callback function whenever changed!"  nope.  doesn't work.  once again: applies entire frameworkelement , not of specific properties.  tried.  (tangent: if can show me any advantages @ using dependency properties on regular properties see it.  far have not found single advantage of dependency properties, , seem complicate code. end tangent)

anyway, so....is there way fire event when any part of property gets changed?

not general case.

regarding tangent, here's reasons use dps:

- automatic change notification callbacks (if register way) called if value changes. (granted isn't tough figure out in own setter.)

- dps can animated. (that has few bugs right now, getting fixed. can animate 1 dp per element right now.)

- attached dps.

- databinding can't sure :)

 



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........