给定一个画布对象:
MainCanvas = new Canvas();
MainCanvas.Name = "myCanvas";
MainCanvas.Height = 100;
MainCanvas.Width = 100;
如何通过代码设置其比例(x
和y
)?
答案 0 :(得分:1)
试试这个:
ScaleTransform scale = new ScaleTransform(MainCanvas.LayoutTransform.Value.M11 * ScaleRate, MainCanvas.LayoutTransform.Value.M22 * ScaleRate);
MainCanvas.LayoutTransform = scale;
MainCanvas.UpdateLayout();