Diagram inside of a zoomed container

The Silverlight application I am working in has a global zoom feature. This works by applying a scale transform to the Visual Root which happens to be a Grid. My diagram is ultimately descended from this grid. When zoomed the diagram’s appearance is zoomed just fine, but I am unable to interact with it in the normal way (selecting, dragging, etc…). It’s like the mouse coordinates are off because of the zoom factor (I haven’t confirmed this though). Do you have any suggestions for fixing this?

I am currently using GoXam v



Just for fun I tried modifying the Draggable Link sample so that the entire outermost Grid had a RenderTransform with ScaleX=“0.7” ScaleY=“1.2”.

The resulting app looked a bit weird with the non-isotropic scaling – everything looked unnaturally tall and thin. But it behaved just fine – I could select, resize, and rotate nodes, and draw and reconnect links. And everything behaved the way I think you would expect.

I’ve now played around with it some more. Right clicking on nodes to bring up the context menu works just fine. Left click to select is not working. We are actually handling selection ourselves in the diagram via a Left Mouse Button Down handler on the data template for nodes. We do this because we needed some custom selection functionality. With the scale transform not there or set to 1 (no scaling) then everything works fine. With the scale tranform set to some actual value first our Left Mouse Button handler gets called and we do what we’ve been doing, but then the diagram framework also handles the click and it ends up deselecting what we’ve just selected (basically it’s cancelling out what we are doing in our custom handling).

I suppose that we can put something in to disable the second click handling by the framework, but I don’t understand why it would be work for the unscaled case and not for the scaled case.

How are you transforming the mouse coordinates? Are you calling MouseEventArgs.GetPosition(myDiagram.Panel) to get the view coordinates? Are you calling myDiagram.Panel.TransformViewToModel to get the model/document coordinates, if you need them?

We aren’t transforming the mouse coordinates anywhere. We are just handling the MouseLeftButtonDown even on a Border control that’s in our Data Template for the nodes.

<Border MouseLeftButtonDown=“Border_MouseLeftButtonDown”>

Does your handler set MouseEventArgs.Handled = true when it does actually “handle” the event to your app’s satisfaction?

It actually looks like there were some cases were Handled was not being set to true. I’ve found some other errors in that code. Hopefully when I clean up that up it’ll fix the problems.

Thanks for you help!