0

I'm trying to create a Shape this way:

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"
            }
        }
    }
};

I've tried similar several combinations to get the path mini-language converted into a Segment collection to no avail. Can someone help?

I know how to do it in XAML, but I need the C# equivalent:

<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" />
mins
  • 6,478
  • 12
  • 56
  • 75
  • 1
    Found this: https://stackoverflow.com/questions/2029680/wpf-c-sharp-path-how-to-get-from-a-string-with-path-data-to-geometry-in-code-n –  May 26 '19 at 15:47
  • @And-RoMarian: Good find, both answers fix my problem. Thanks. Suggest to close this question as duplicate. – mins May 26 '19 at 15:55

0 Answers0