我目前正在尝试将WPF的BezierSegment
添加到 Canvas 上。我收到一个不正确的转换的编译时错误:
这是我到目前为止所拥有的...
//bezier curve it
BezierSegment curve = new BezierSegment(startPoint, endPoint,controlPoint,false);
// Set up the Path to insert the segments
PathGeometry path = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = hs.LeStartingPoint;
pathFigure.IsClosed = true;
path.Figures.Add(pathFigure);
pathFigure.Segments.Add(curve);
System.Windows.Shapes.Path p = new Path();
p.Data = path;
this.mainWindow.MyCanvas.Children.Add(path);
任何帮助将不胜感激!
最佳答案
您必须将p
(Path
)添加到Canvas
,而不是path
(PathGeometry
)。
BezierSegment curve = new BezierSegment(new Point(11,11), new Point(22,22), new Point(15,15), false);
// Set up the Path to insert the segments
PathGeometry path = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(11, 11);
pathFigure.IsClosed = true;
path.Figures.Add(pathFigure);
pathFigure.Segments.Add(curve);
System.Windows.Shapes.Path p = new Path();
p.Stroke = Brushes.Red;
p.Data = path;
MyCanvas.Children.Add(p); // Here
关于c# - 将(BezierSegment添加到) Canvas 路径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17766425/