Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用DataTemplate将WPF数据绑定到路径_C#_Wpf - Fatal编程技术网

C# 使用DataTemplate将WPF数据绑定到路径

C# 使用DataTemplate将WPF数据绑定到路径,c#,wpf,C#,Wpf,我有这个路径 <Path Stroke="Blue" StrokeThickness="2"> <Path.Data> <PathGeometry> <PathFigureCollection> <PathFigure StartPoint="20, 130"> <PathFigure.Segments> <LineSegment Po

我有这个
路径

<Path Stroke="Blue" StrokeThickness="2">
  <Path.Data>
    <PathGeometry>
      <PathFigureCollection>
        <PathFigure StartPoint="20, 130">
          <PathFigure.Segments>
            <LineSegment Point="40, 4"/>
            <LineSegment Point="60, 132"/>
          </PathFigure.Segments>
        </PathFigure>
      </PathFigureCollection>
    </PathGeometry>
  </Path.Data>

有人告诉我,它可以用


在某些
ItemSource

这看起来像是真的,因为坐标是
(SegmentWidth,y_1),(SegmentWidth*2,y_2),…,(SegmentWidth*n,y_n)

但是我不知道如何为这个
路径制作
DataTemplate
。我被告知应该在没有“代码隐藏”的情况下完成

如果使用多段线比使用路径更容易实现,它仍然很好。我唯一的目标是使用坐标将XML(第二个代码块)转换为类似于多段线的图形
(SegmentWidth,Sample Val 1),…,(SegmentWidth*n,Sample Val n)

<Nums Color="Blue" Thick="2" SegmentWidth="20">
  <Sample Val="130" />
  <Sample Val="4" />
  <Sample Val="132" />
</Nums>