I am trying to create a method for drawing a line (path) between two UserControls. I found a message from someone that gave me a general pointer on how to do this, I successfully implemented the code and started adapting it to my needs.
I had a problem accessing a user control:
Button b2 = new Button();
var transform2 = b2.TransformToVisual(b2.Parent as UIElement);
It works as it should, but my buttons are created dynamically using the method, so I can’t access them as "b2".
I tried the following:
var transfrom3 = canvas1.Children[0].TransformToVisual(canvas1.Children[0].Parent as UIElement);
but accessing it seems to give me a .Parent error.
If you also tried:
var p1 = this.FindName(ps.ProcessID.ToString());
var p2 = this.FindName(ps.PreID.ToString());
var transform1 = p1.TransformToVisual(p1.Parent as UIElement);
var transform2 = p2.TransformToVisual(p2.Parent as UIElement);
Can someone tell me how can I access these UserControls?
source
share