1

I am trying to draw a line in a windows 8 app in c#. However, when I try to use

Line myLine = new Line(); it does not work and tells me the namespace does not exist.

Using LineGeometery myLine = new LineGeometery (); does appear to create a new line and I can set the start and end points. However, as I cannot set the stroke, I really do not know if this is the correct approach. In fact, I am unsure on the difference between LineGeometery() and Line().

If anyone could help, that would be very appreciated.

<code>using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using Windows.Foundation;

using Windows.Foundation.Collections;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Controls.Primitives;

using Windows.UI.Xaml.Data;

using Windows.UI.Xaml.Input;

using Windows.UI.Xaml.Media;

using Windows.UI.Xaml.Navigation;</code>
4

1 回答 1

6

请在您的应用程序中添加以下使用。Windows.UI.Xaml.Shapes

Line 类位于 Windows.UI.Xaml.Shapes 命名空间中。

这是我用来向名为 LayoutRoot 的网格添加一条线的代码部分

Line line = new Line();
line.X1 = 10;
line.X2 = 200;
line.Y1 = 10;
line.Y2 = 200;
line.Stroke = new SolidColorBrush(Colors.Red);
LayoutRoot.Children.Add(line);
于 2012-12-13T07:36:40.080 回答