c# - Resize WPF Canvas control not maintaining aspect ratio correctly -


i using resize code this answer works when testing when placed real application (with larger render time) aspect ratio no no longer maintained. if move mouse or wiggle in directions can make control distort out of original aspect ratio , seems happen once in actual application.

i'm not 100% sure wonder if because uses actualheight , actualwidth calculate current ratio , values might not date.

some of related code, rest available on question linked above:

called on drag

this.checkaspectratio(ref dragdeltahorizontal, ref dragdeltavertical, item.actualheight / item.actualwidth); 

the function itself

private void checkaspectratio(ref double? dragdeltahorizontal, ref double? dragdeltavertical, double aspectratio) {     double? dragvalue = null;     if (dragdeltavertical.hasvalue && dragdeltahorizontal.hasvalue)     {         dragvalue = math.max(dragdeltavertical.value, dragdeltahorizontal.value);     }     else if (dragdeltavertical.hasvalue)     {         dragvalue = dragdeltavertical;     }     else if (dragdeltahorizontal.hasvalue)     {         dragvalue = dragdeltahorizontal;     }      if (dragvalue.hasvalue)     {         dragdeltavertical = dragvalue.value * aspectratio;         dragdeltahorizontal = dragvalue;     } } 


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -