0

I am developing a C# application and I am drawing two components programmatically. However, I would like to make them connected (using line) so that when I move one component, I can change the coordinates of another object.

For example: Suppose there are two squares on Canvas and they are connected using a line. When a move one square, I also want to change the coordinates of another square. So, another square will also seem like moving relative to first one.

I would really appreciate if someone could help me out in second part. I think it can be done using dependency properties but I wasn't able to find an example.

Vinit Sharma
  • 461
  • 2
  • 8
  • 16
  • Just attach a `MouseMove` handler to the first object and then move the second object from there... nothing to do with `DepenedencyProperty`s. – Sheridan Sep 29 '14 at 13:07
  • Yes that's true. But in this case, I would to manually alter the coordinates of every other component. So, I wanted to know is there any other alternative – Vinit Sharma Sep 29 '14 at 13:12
  • 2
    You'd only ever need to update 2 values: `Canvas.Top` and `Canvas.Left`. – Sheridan Sep 29 '14 at 13:14
  • From your terminology, it seems that you're approaching this with a winforms mentality, which is not compatible with WPF. See [My Example](http://stackoverflow.com/a/15580293/643085) which shows how to do this in a proper WPF way using WPF techniques. – Federico Berasategui Oct 16 '14 at 16:37
  • I am still not sure. How to do that – Vinit Sharma Oct 16 '14 at 16:41

0 Answers0