XAML Line Element

A quick article explaining how to use the XAML element. It’s something that bugged me and took longer than it should have.

I wanted to draw a simple horizontal line. It’s only when I read the Microsoft documentation that I realised a few key points.

  • You must specify a StrokeThickness.
  • You must specify a Stroke (i.e. White). Don’t bother with Fill
  • Width and Height specify the space your line is in
  • The coordinates (X1, X2, Y1, Y2) define the detail of your line within the space

If you want a simple horizontal line in red, you can do this:

[code lang="xml”] [/code]

And here’s an example of a more complicated line, more akin to the slash / character:

[code lang="xml”] [/code]