title: C# WPF how to draw an arc in a grid through code behind
body: <p>I have a grid which adapts to columns and rows.
  In that grid I have to draw an arc which extends and stretches to the Whole parent grid.</p>
  
  <p>I have tried that</p>
  
  <pre><code>Canvas cnv = new Canvas();
  Path pth = new Path() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
  PathGeometry pg = new PathGeometry();
  PathFigureCollection pfc = new PathFigureCollection();
  PathFigure pf = new PathFigure();
  
  ArcSegment a = new ArcSegment(new Point(0, 0), new Size(300, 300), 45, true, SweepDirection.Clockwise, true);
  
  cnv.Children.Add(pth);
  pth.Data = pg;
  pfc.Add(pf);
  pg.Figures = pfc;
  pf.Segments.Add(a);
  grd.Children.Add(cnv);
  </code></pre>
  
  <p>but nothing appears.</p>
  
  <p>Additionally I am wondering if there is a more straithforward solution to achieve the goal.</p>
  
  <p>And then, I don't want to set the size of the arc, I want it to stretch to the parent size, possibly with a margin.</p>
  
  <p>Thank you very much</p>