私はwpfでパスを使用する際に新しいですし、xamlコードのセグメントをC#コードに変換する方法がわかりません。誰かが私にこれを手伝ってもらえますか?私はxamlコードに続いてそれを変換しようとしています。 C#コードには何が欠けていますか?私が尋ねたいもう一つのことは、グリッドが十分なので、ウィンドウに表示されるパスであるかどうかです。 xamlをC#コードに変換する
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<QuadraticBezierSegment Point1="200,200" Point2="300,100" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
私のC#コード:
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = new PathFigureCollection();
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 100);
myPathFigure.Segments = new PathSegmentCollection();
QuadraticBezierSegment theSegment = new QuadraticBezierSegment();
theSegment.Point1 = new Point(200, 200);
theSegment.Point2 = new Point(100, 300);
myPathFigure.Segments.Add(theSegment);
myPathGeometry.Figures.Add(myPathFigure);
ありがとうございます。私はすでにデータを追加しましたが、私はmyGrid.Children.Add(myPath)を見逃していました。 – arjacsoh