UWP - Line example

MainPage.xaml

<Page
    x:Class="UniversalAppTutorials.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UniversalAppTutorials"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <StackPanel 
        x:Name="StackPanel1" 
        Margin="50" 
        Orientation="Vertical"
        Background="AliceBlue"
        Padding="50"
        >
        <Line
            Stroke="Red"
            X2="400"
            Margin="10"
            />
        <Line
            Stroke="Indigo"
            X1="200"
            X2="500"
            Margin="10"
            />
        <Line
            Stroke="DarkBlue"
            X2="350"
            Margin="10"
            StrokeThickness="5"
            />
        <Line
            Stroke="HotPink"
            StrokeThickness="7"
            StrokeDashOffset="5"
            StrokeDashArray="1,2,3"
            X2="500"
            Margin="20"
            />
    </StackPanel>
</Page>
MainPage.xaml.cs

using Windows.UI.Xaml.Controls;
using Windows.UI;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
using Windows.UI.Xaml;


namespace UniversalAppTutorials
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            // Create a line
            CreateLine();
        }

        private void CreateLine()
        {
            // Initialize a new line instance
            Line line = new Line();

            // Set line X2
            line.X2 = 450;

            // Set line color
            line.Stroke = new SolidColorBrush(Colors.Black);

            // Set line width/thickness
            line.StrokeThickness = 10;

            // Add margin to the line
            line.Margin = new Thickness(10, 10, 10, 0);

            // Finally, add the line to layout
            StackPanel1.Children.Add(line);
        }
    }
}
More uwp tutorials