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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -