WPF - Path Geometry ... Is there a way to bind a data property?

I have a ControlTemplate that is used as the β€œBubble” AdornerLayer on this AdornerLayer control.

It works fine, but I need to figure out where it should be displayed (middle / bottom).

Instead:

 <Path Stroke="Black" Fill="Black" Data="M 15 20 L 15 0 33 20" Margin="0 1 0 0"/> 

I am looking (obviously this will not work, but this illustrates what I am trying to accomplish:

 <Path Stroke="Black" Fill="Black" Data="M {TemplateBinding Left} 20 L 15 0 33 20"/> 

Can this be done using ValueConverter ? For some reason, I just can't imagine a solution. I am also open to alternatives.

Thanks for reading, and if I can provide more information, just ask.

+4
source share
1 answer

If you need a value converter that you can use to convert a string to path data, you can try a universal value converter. I wrote some time ago.

As an alternative to binding to a single property, you will need to expand your geometry by adding various geometry objects to your XAML, instead of using a shorthand string. For instance...

 <Path Stroke="Black" StrokeThickness="1"> <Path.Data> <PathGeometry> <PathGeometry.Figures> <PathFigureCollection> <PathFigure IsClosed="True" StartPoint="10,100"> <PathFigure.Segments> <PathSegmentCollection> <LineSegment Point="{Binding MyPropertyPath}" /> <LineSegment Point="100,50" /> </PathSegmentCollection> </PathFigure.Segments> </PathFigure> </PathFigureCollection> </PathGeometry.Figures> </PathGeometry> </Path.Data> </Path> 
+7
source

All Articles