Question: I am new at using path in a wpf and I do not know how to convert a segment of xaml code to C# code. Could someone help me with this? I cite following the xaml code and then my attempt to convert it. What the C# code lacks of? One more thing I 'd like to ask is if a grid is enough so as a path to appear in the window.

```xml
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
  <PathGeometry.Figures>
    <PathFigureCollection>
      <PathFigure StartPoint="10,100">
        <PathFigure.Segments>
          <PathSegmentCollection>
            <QuadraticBezierSegment Point1="200,200" Point2="300,100" />
          </PathSegmentCollection>
        </PathFigure.Segments>
      </PathFigure>
    </PathFigureCollection>
  </PathGeometry.Figures>
</PathGeometry>

```

My C# code:

```
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = new PathFigureCollection();

PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 100);
myPathFigure.Segments = new PathSegmentCollection();
QuadraticBezierSegment theSegment = new QuadraticBezierSegment();
theSegment.Point1 = new Point(200, 200);
theSegment.Point2 = new Point(100, 300);
myPathFigure.Segments.Add(theSegment);
myPathGeometry.Figures.Add(myPathFigure);

```

Answer: 
You have to add following line at the end,

```
myPath.Data = myPathGeometry;

```

And you should add x:Name to your `<Grid>` as `<Grid x:Name='myGrid'>`

And add one more line,

```
myGrid.Children.Add(myPath);

```
Your C# code could look a lot like the WPF markup. Just add the path to the control you wish to display it in.

```
var myPath = new Path
{
    Stroke = Brushes.Black,
    StrokeThickness = 1.0,
    Data = new PathGeometry
    {
        Figures = new PathFigureCollection
        {
            new PathFigure
            {
                StartPoint = new Point(10, 100),
                Segments = new PathSegmentCollection
                {
                    new QuadraticBezierSegment
                    {
                        Point1 = new Point(200, 200),
                        Point2 = new Point(300, 100),
                    },
                },
            },
        },
    },
};
myGrid.Children.Add(myPath);

```