我正在尝试通过以下方式创建形状:
Shape shape = new Path {
StrokeThickness = 3,
Stroke = Brushes.Coral, Fill = Brushes.Purple,
Data = new PathGeometry {
Figures = new PathFigureCollection {
new PathFigure {
Segments = "M 15,0 H 20 V 15 H 35 V 20 H 20 V 35 H 15 V 20 H 0 V 15 H 15 Z"
}
}
}
};
我尝试了类似的几种组合,以将路径迷你语言转换为Segment集合无济于事。有人可以帮忙吗?
我知道如何在XAML中做到这一点,但我需要C#等效项:
<Path StrokeThickness="3"
Stroke="Coral" Fill="Purple"
Data="M 15,0 H 20 V 15 H 35 V 20 H 20 V 35 H 15
V 20 H 0 V 15 H 15 Z" />