Draw Diagonal Line in WPF Grid
grid, wpf
Solution
You could use a Path with Stretch=Fill. For the top right cell in your example, you would use:
<Path Grid.Row="2" Grid.Column="0" Stroke="Red" StrokeThickness="2" Stretch="Fill">
<Path.Data>
<LineGeometry StartPoint="0,0" EndPoint="1,1" />
</Path.Data>
</Path>
The "Fill" stretch makes the Path stretch to fill its parent, which gives the impression that the coordinates of the LineGeometry are relative (X=0,Y=0 is top left, X=1,Y=1 is bottom right).
Problem
I think I am trying to do something relatively simple in WPF, but can't for the life of me figure out how; and think I am probably on the verge of overcomplicating it. If I had a grid which was 3 rows and 3 columns, and I wanted to join the corners of two cells to create a diagonal border, what would be the best way of doing so? The lines should ideally re-size if the control is resized (so bound to the corners of the cell?). Essentially I would like to create the red lines in the diagram hosted here: Example Pic http://imm.io/7A4L