Question

I have a WPF TreeView that represents an object graph in which some objects implicitely references each others.

For those, I'd like to be able to draw an arrow linking them when I select one of them:

enter image description here

I looked into the Adorners but I am not sure it's the correct way to go since I cannot find a way to get the graphical position of two items in the TreeView...

Any idea what I could do here?

Was it helpful?

Solution

first, you could get the relative item position with this:

var myItem = (UIElement)myTreeView.SelectedItem;
var pos1 = myItem.TranslatePoint(new Point(), myTreeView);
var pos2 = myAnyOtherItem.TranslatePoint(new Point(), myTreeView);

if you don't have access to the UIElement look for
"get container from data object (WPF TreeView)"
but this is a other question and I'm sure there is already a solution ^^

second, using an adorner is good idea
but I'm sure there are enough samples ^^

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top