0

How to create the following xaml in code:

  <Canvas>
         <Path Width="38" Height="9" 
Canvas.Left="-15" Canvas.Top="-1" 
Stretch="Fill" Fill="#FFF2F2F2" 
Data="F1 M 0.684,18.073 L12.790,5.968 L12.790,14.385 L54.794,14.385 L54.794,21.761 L12.790,21.761 L12.790,30.178 Z "/>
</Canvas>
EngineerSpock
  • 2,575
  • 4
  • 35
  • 57

2 Answers2

2

According to this answer: https://stackoverflow.com/a/2029805/1683224

You can do this:

var path = new Path();
path.Data = Geometry.Parse("F1 M 0.684,18.073 L12.790,5.968 L12.790,14.385 L54.794,14.385 L54.794,21.761 L12.790,21.761 L12.790,30.178 Z");

Then change the other properties of path as you need.

Community
  • 1
  • 1
Wiley Marques
  • 485
  • 3
  • 16
0

Create a new instance of Path and in the Data field, parse these F1 M 0.684,18.073 L12.790,5.968 L12.790,14.385 L54.794,14.385 L54.794,21.761 L12.790,21.761 L12.790,30.178 Z with the Geometry class.

for the position, use the SetValue method of framework element like path.SetValue(Canvas.LeftProperty, -15)

Sankarann
  • 2,625
  • 4
  • 22
  • 59