Populate the PointsCollection of the PolyLine
<UserControl x:Class='SilverlightApplication3.MainPage'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'
mc:Ignorable='d'
d:DesignWidth='640'
d:DesignHeight='480'>
<Canvas>
<TextBlock Canvas.Top="40" Canvas.Left="20"
FontSize="14" Text="Static Points Collection" />
<Polyline Stroke="Black" StrokeThickness="3"
Points="0,0 300,10 300,10 10,10 10,25
250,250 255,85 250,40 205,85 200,40 155,85 35,90" />
<TextBlock Canvas.Top="150" Canvas.Left="20" Text="Programmatic Points Collection" />
<Polyline Name="plLine" Stroke="Black" StrokeThickness="3" />
</Canvas>
</UserControl>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace SilverlightApplication3
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
plLine.Points.Add(new Point(10, 140));
plLine.Points.Add(new Point(270, 140));
plLine.Points.Add(new Point(10, 175));
plLine.Points.Add(new Point(10, 220));
plLine.Points.Add(new Point(125, 220));
}
}
}
Related examples in the same category