使用Polygon

时间:2019-01-14 17:21:44

标签: c# wpf

当我在WPF画布上绘制具有普通顶点的三角形时,遇到了一些边缘太长的问题as you can see here.,我尝试禁用了消除锯齿功能,但这只会使不匹配更加明显。

有问题的代码:

<ItemsControl ItemsSource="{Binding Triangles}" Grid.Row="0" Grid.Column="0" ClipToBounds="True" Margin="5,5,2.5,2.5">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas SnapsToDevicePixels="True" Background="#FF141E22"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Polygon Points="{Binding Points}" Stroke="LightYellow" StrokeThickness="1"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

Triangles = new Triangle3D[3];
Triangles[0] = new Triangle3D(new List<Point>() { new Point(250, 50), new Point(150, 150), new Point(50, 150) });
Triangles[1] = new Triangle3D(new List<Point>() { new Point(150, 150), new Point(50, 150), new Point(250, 250) });
Triangles[2] = new Triangle3D(new List<Point>() { new Point(150, 150), new Point(250, 50), new Point(250, 250) });

0 个答案:

没有答案