Dennis He
Dennis He

Reputation: 29

How to Convert WPF Path Data in C# Code (Geometry)

I think it is a easy Question for WPF experts but too hard for me, right now.

How do i convert this to C# Code:

<Path Fill="Red" Data="M150,300 L300,300 A150,150 0 0 0 256,194 z">

To Something like this:

Path p = new Path();
p.Data = Geometry...?
EllipseGeometry eg = new EllipseGeometry()
...?

Upvotes: 1

Views: 1394

Answers (1)

mm8
mm8

Reputation: 169170

Try this:

System.Windows.Shapes.Path p = new System.Windows.Shapes.Path();
p.Fill = Brushes.Red;
p.Data = Geometry.Parse("M150,300 L300,300 A150,150 0 0 0 256,194 z");

Upvotes: 2

Related Questions