I am using LayoutTransform for zooming in and out of my canvas and is working exactly the way I want (almost).
I have a small problem though. Its not taking mouse location as center for ZoomIn or ZoomOut. It always takes top left corner (0,0) for this operation.
Here is my code:
private void ZoomIn()
//Get the current matrix
Matrix currentMattrix = this.canvas.LayoutTransform.Value;
double mouseX = Mouse.GetPosition(this.canvas).X;
double mouseY = Mouse.GetPosition(this.canvas).Y;
//Zoom in by increasing the scale transofrm
this.canvas.LayoutTransform = new ScaleTransform(currentMattrix.M11 + 0.1, currentMattrix.M22 + 0.1, mouseX, mouseY);
View Complete Post