Get the normal position of a node

I try to do an effect: zoom a node and change it with an user control, but i can’t have the “normal” position of the node, just some relative in a strange coordinate system. What i want is position as in mouseevent. I am lost, any idea ?

I’m not sure what you mean by “zoom a node”. If you could describe more precisely the effect you want, I can tell you how to achieve it.

There are two notions for a node’s “position”: the Node.Position and the Node.Location. Both are in model coordinates. Most operations work on the Node.Location. So I think the Node.Location is usually its “normal” position.

Node.Position is just the same as the Part.Bounds’s X,Y point.

Node.Location is the point corresponding to a spot on the Node.LocationElement, which defaults to the top-left point of the bounds of the whole Part.VisualElement – i.e. the same as the Node.Position.

However, if you want to assume that the location of a node is actually the center of its primary icon, you can do that by setting Node.LocationElementName to the x:Name of the icon and Node.LocationSpot to Spot.Center.

You can use Part.GetElementPoint and/or Part.GetElementBounds to get the Point or the Rect in model coordinates of any FrameworkElement in your Node.

You can convert a MouseEventArgs position to viewport coordinates and to model coordinates by:

MouseEventArgs e = ...; Point viewpos = e.GetPosition(myDiagram.Panel); Point modelpos = myDiagram.Panel.TransformViewToModel(viewpos);In other words, all mouse events are transformed relative to the DiagramPanel, to get view coordinates. The modelpos above will be in model coordinates and will be the same as the value of Diagram.LastMousePointInModel.

For resume, my tree is in a canvas, and i want the coordinate in the canvas layout, not in the tree layout, and i didn’t find a fonction for transform from one to other. thanks for quick answer!