日期:2014-05-17 浏览次数:21083 次
private void CreateAPolyline()
{
// Create a blue and a black Brush
SolidColorBrush yellowBrush = new SolidColorBrush();
yellowBrush.Color = Colors.Yellow;
SolidColorBrush blackBrush = new SolidColorBrush();
blackBrush.Color = Colors.Black;
// Create a polyline
Polyline yellowPolyline = new Polyline();
yellowPolyline.Stroke = blackBrush;
yellowPolyline.StrokeThickness = 4;
// Create a collection of points for a polyline
System.Windows.Point Point1 = new System.Windows.Point(10, 100);
System.Windows.Point Point2 = new System.Windows.Point(100, 200);
System.Windows.Point Point3 = new System.Windows.Point(200, 30);
System.Windows.Point Point4 = new System.Windows.Point(250, 200);
System.Windows.Point Point5 = new System.Windows.Point(200, 150);
PointCollection polygonPoints = new PointCollection();
polygonPoints.Add(Point1);
polygonPoints.Add(Point2);
polygonPoints.Add(Point3);
polygonPoints.Add(Point4);
polygonPoints.Add(Point5);
// Set Polyline.Points properties
yellowPolyline.Points = polygonPoints;
// Add polyline to the page
LayoutRoot.Children.Add(yellowPolyline);
}