WPF 2D绘图(1)Shape - 图1
    特点:

    1. 使用XAML输出
    2. 继承自FrameworkElement的,因此拥有了众多的属性和事件

    1.Ellipse

    1. <Canvas Height="200" Width="250" HorizontalAlignment="Left">
    2. <Ellipse
    3. Width="100"
    4. Height="50"
    5. Fill="#CCCCFF"
    6. Canvas.Left="10"
    7. Canvas.Top="25" />
    8. <Ellipse
    9. Width="100"
    10. Height="50"
    11. Fill="#CCCCFF"
    12. Stroke="Black"
    13. StrokeThickness="4"
    14. Canvas.Left="10"
    15. Canvas.Top="100"/>
    16. <Ellipse
    17. Width="50"
    18. Height="50"
    19. Fill="#CCCCFF"
    20. Canvas.Left="135"
    21. Canvas.Top="25"/>
    22. <Ellipse
    23. Width="50"
    24. Height="50"
    25. Stroke="Black"
    26. StrokeThickness="4"
    27. Canvas.Left="135"
    28. Canvas.Top="100" />
    29. </Canvas>

    WPF 2D绘图(1)Shape - 图2
    2.Rectangles

    1. <Canvas Height="200" Width="250" HorizontalAlignment="Left">
    2. <Rectangle
    3. Width="100"
    4. Height="50"
    5. Fill="#CCCCFF"
    6. Canvas.Left="10"
    7. Canvas.Top="25" />
    8. <Rectangle
    9. Width="100"
    10. Height="50"
    11. Fill="#CCCCFF"
    12. Stroke="Black"
    13. StrokeThickness="4"
    14. Canvas.Left="10"
    15. Canvas.Top="100"/>
    16. <Rectangle
    17. Width="100"
    18. Height="50"
    19. RadiusX="20"
    20. RadiusY="20"
    21. Fill="#CCCCFF"
    22. Canvas.Left="135"
    23. Canvas.Top="25"/>
    24. <Rectangle
    25. Width="100"
    26. Height="50"
    27. RadiusX="20"
    28. RadiusY="20"
    29. Stroke="Black"
    30. StrokeThickness="4"
    31. Canvas.Left="135"
    32. Canvas.Top="100" />
    33. </Canvas>

    WPF 2D绘图(1)Shape - 图3

    3.Polygon

    1. <Canvas Height="300" Width="270" HorizontalAlignment="Left">
    2. <Polygon
    3. Points="10,110 60,10 110,110"
    4. Fill="#CCCCFF" />
    5. <Polygon
    6. Points="10,110 60,10 110,110"
    7. Fill="#CCCCFF"
    8. Stroke="Black"
    9. StrokeThickness="4"
    10. Canvas.Top="150" />
    11. <Polygon
    12. Points="10,110 110,110 110,10"
    13. Fill="#CCCCFF"
    14. Canvas.Left="150" />
    15. <Polygon
    16. Points="10,110 110,110 110,10"
    17. Stroke="Black"
    18. StrokeThickness="4"
    19. Canvas.Left="150"
    20. Canvas.Top="150" />
    21. </Canvas>

    WPF 2D绘图(1)Shape - 图4
    4.Polyline

    1. <Canvas Height="150" Width="300" HorizontalAlignment="Left" VerticalAlignment="Top">
    2. <Polyline
    3. Points="10,110 60,10 110,110"
    4. Stroke="Black"
    5. StrokeThickness="4" />
    6. <Polyline
    7. Points="10,110 110,110 110,10"
    8. Stroke="Black"
    9. StrokeThickness="4"
    10. Canvas.Left="150" />
    11. </Canvas>

    WPF 2D绘图(1)Shape - 图5

    5.Line

    1. <Canvas Height="100" Width="250" HorizontalAlignment="Left">
    2. <Line
    3. X1="10" Y1="10"
    4. X2="50" Y2="50"
    5. Stroke="Black"
    6. StrokeThickness="4" />
    7. <Line
    8. X1="10" Y1="10"
    9. X2="50" Y2="50"
    10. Stroke="Black"
    11. StrokeThickness="4"
    12. Canvas.Left="100" />
    13. </Canvas>

    WPF 2D绘图(1)Shape - 图6