I'm trying to use manipulation to rescale a canvas. On debugging the below code it seems that canImage.Width and canImage.Heigh both get set to NaN
. I don't understand how a double times a double can give Nan
(width ~ 400 Height ~400 e.scale.y ~-1.5 e.Scale.X ~0.3)
.
private void viewer_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
if (e.TotalManipulation.Scale.X != 0 && e.TotalManipulation.Scale.Y != 0) {
canImage.Width = mainImage.Width * (double)e.TotalManipulation.Scale.X;
canImage.Height = mainImage.Height * (double)e.TotalManipulation.Scale.Y;
}
}
EDIT: Just put a conditional breakpoint in and it seems e.TotalManipulation.Scale.X
and e.TotalManipulation.Scale.X
are never NaN
. Putting the e.TotalManipulation.Scale.X > 0
condition did stop the issue. It looks like setting Height/Width to something less than one just causes them to become NaN rather than just falling over. Thanks for all your help