CanvasDrawingSession drawSession = canvas.CreateDrawingSession(); drawSession.DrawLine(new Vector2(0, 0), new Vector2(100, 100), Colors.Black);
CanvasStrokeStyle strokeStyle = new CanvasStrokeStyle(); strokeStyle.DashStyle = CanvasDashStyle.Dash; CanvasDrawingSession drawSession = canvas.CreateDrawingSession(); drawSession.DrawLine(new Vector2(0, 0), new Vector2(100, 100), Colors.Red, 5, strokeStyle);This example demonstrates how to draw a dashed line using the DrawLine method. A stroke style object is created and set with the DashStyle property. The DrawLine method is then called with the new stroke style object, which results in a dashed line being drawn with red color. Package library: Windows.Graphics.Canvas. Note: The examples assume that a Canvas control has already been created and named "canvas".