The ruler (InkPresenterRuler
) in the inktoolbar doesn't display correctly when the InkCanvas
is a child of the Viewbox
.
Anyone got any idea how to fix it?
After hours of trying and error, this is what I have however I couldn't get the ruler display in a diagonal direction.
private void ResizeInkRuler() {
var viewBoxWidth = ImageViewBox.ActualWidth;
var viewBoxHeight = ImageViewBox.ActualHeight;
var widthIsGreater = viewBoxWidth.CompareTo(viewBoxHeight) > 0;
var scaleFactor = widthIsGreater ? InkImage.ActualWidth / viewBoxWidth : InkImage.ActualHeight / viewBoxHeight;
var length = widthIsGreater ? viewBoxWidth : viewBoxHeight;
ruler.Transform = Matrix3x2.CreateScale((float) scaleFactor);
ruler.Length = length;
}