/// <summary> /// Called when the size has changed. /// </summary> void MySizeChanged(object sender, SizeChangedEventArgs e) { Point dpi = WFUtils.GetResolution(this); dpiScaleX = dpi.X / 96.0; dpiScaleY = dpi.Y / 96.0; int width = (int)(ActualWidth * dpiScaleX); int height = (int)(ActualHeight * dpiScaleY); bitmap = new WriteableBitmap(width, height, dpi.X, dpi.Y, PixelFormats.Pbgra32, null); image.Source = bitmap; pixelMapper.Init(this); Redraw(); }