Why am I limited to 1000 characters in a reply???
I'll have to break up what I was going to say into multiple replies ... I have no idea how one would post any code with such a small limit.
The work area where the nodes and flow lines are placed is a Canvas in a ScrollViewer.
In the XAML:
The ScrollViewer has InputBindings like this:
<KeyBinding Gesture="Down"
Command="{Binding Move}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Gesture}" />
There is a DataTemplate that defines what a node is displayed like.
<DataTemplate>
<local:NodeIcon Focusable="True"
Icon="{Binding Icon}"
IsModified="{Binding HasBeenModified}"
IsSelected="{Binding IsSelected}"
Location="{Binding Location}"
...
>
<local:NodeIcon.ContextMenu>
<ContextMenu>
...
</ContextMenu>
</local:NodeIcon.ContextMenu>
</local:NodeIcon>
</DataTemplate>
NodeIcon is a custom control based on Canvas that basically shows a central icon surrounded by a small constellation of little icons that are shown or hidden based on other properties, like IsModified, and defines a bunch of dependency properties for them all as well as the Location and other things.
The view model's ICommand for the Move binding calls into a method named MoveExecute.
MoveExecute casts the parameter received as object to a KeyGesture and then passes it to a subroutine named MoveSelection.
MoveSelection goes through the list of node view models and collects those where the IsSelected property is true.
Then it adjusts their Location property (a Point) based on the KeyGesture.
Ex. if the Gesture is the Down one show above, it adds something like 30 to the Y of the Location.
The NodeIcon.Location dependency property's changed method uses a helper method to walk up the visual tree to find the ContentControl that the data template for the node is actually expanded into, then it uses Canvas.SetTop and Canvas.SetLeft on that content control using the Point that was received via the binding. That causes the node to move to the new location.
There may be a lot of code in this application, but there really isn't much going on for moving the nodes around on the screen. And they move just fine ... never had a problem with that. It is just that right after moving a bunch of nodes several times the context menus on the nodes that were moved as well as the context menu on the Canvas (white space between nodes) and other popup type things within the same area of the visual tree, all start showing up in the wrong place.
Most often the context menus show up in the top left corner of screen 1, but occasionally they will display some distance directly to the right of where they should, and even more rarely will display with the bottom cropped off (the frame and some items are just not there) almost as if it were sticking off screen even though it is nowhere near the bottom of the screen, and context menus normally can only stick off screen if they are taller than the entire screen.