我在xaml中有以下路径数据.我想从后面的代码中定义相同的路径数据.
<Path Data="M 250,40 L200,20 L200,60 Z" />
解决方法
来自Codebehind:
Path orangePath = new Path(); Pathfigure pathfigure = new Pathfigure(); pathfigure.StartPoint = new Point(250,40); Linesegment linesegment1 = new Linesegment(); linesegment1.Point = new Point(200,20); pathfigure.Segments.Add(linesegment1); Linesegment linesegment2 = new Linesegment(); linesegment2.Point = new Point(200,60); pathfigure.Segments.Add(linesegment2); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.figures = new PathfigureCollection(); pathGeometry.figures.Add(pathfigure); orangePath.Data = pathGeometry;
编辑:
//我们必须设置为true才能将linesegment2中的行绘制到起始点
pathfigure.IsClosed = true;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。