Search code examples
wpfdrawinglines

Drawing lines between elements in WPF


What is a good approach for drawing lines between elements in WPF?

I have a view in my application with several buttons that make up a diagram. They scale and move depending on the view's size and shape. I would like to indicate a relationship between some of the buttons using a line.

I am not using a Canvas to lay everything out because I want the buttons' relative positions to be dynamic, and I do not want everything to scale at the same rate (like a ViewBox does).


Solution

  • My solution was to use a Grid with a Canvas and my elements in the same cell. I drew the lines in the Canvas in my code-behind file.