【问题标题】:Why the line is empty为什么行是空的
【发布时间】:2013-07-24 10:51:23
【问题描述】:

更新:

原因:

strokeCollection 是我从某处获得的数据。 然后我将其更改为 Path.Data,如下所示:

foreach (var stroke in strokeCollection)
{
    pathGeometry.AddGeometry(stroke.GetGeometry());
}

不幸的是,GetGeometry 方法会给我一个类似 1 的路径。它是空的。 为了确保笔触已经全部包含在路径中,GetGeometry方法是笔触的边框。

问题:

当我将 strokethickness 设置为 1px 时,该行是空的。像 1.

 <Path Stroke="Red" StrokeThickness="1" Data="{Binding PathData}" />

然后我将线条的填充绑定到笔画。它更改为 2

 <Path Stroke="{Binding Stroke}" Fill="{Binding Stroke}" StrokeThickness="1" Data="{Binding PathData}" />

我认为它的厚度是 2px。

我把线条粗细改成10px,描边改成#1AFF0000,改成4

behidecode.cs:

Stroke = new SolidColorBrush("#1AFF0000");

xaml:

<Path Stroke="{Binding Stroke}" Fill="{Binding Stroke}" StrokeThickness="10" Data="{Binding PathData}" />

问题

  1. 如何画实线,宽度为1px?

  2. 如何清除4中的暗红色?

【问题讨论】:

  • 什么是3?你的数据是什么?
  • 如果你想画线,那么你可以直接使用线对象..为什么使用路径?
  • 3 是两条相交的线。他们的交点是白色的。我不希望它出现。
  • @tanuj_loop 哦,我的错,是路径,不是线。
  • @CédricBignon 数据是从 Stroke 转换而来的。我使用 Stroke.GetGeometry()。这就是原因?

标签: c# wpf path geometry


【解决方案1】:

看看 GemiiniYellow 实际上你的数据部分有问题我已经检查了如何绘制路径的基本知识并发现它工作正常这里是代码。

  <Path Stroke="DarkGoldenRod" StrokeThickness="2" 
Data="M 100,100 100,100 400,100 100,100" />

这是一条完美的线..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-06
    • 2012-11-30
    • 2021-12-08
    • 2019-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-10
    相关资源
    最近更新 更多