WPF-路径几何...是否有绑定数据属性的方法? [英] WPF - Path Geometry...Is there a way to bind the Data Property?
问题描述
我有一个ControlTemplate
,它用作给定控件的AdornerLayer
上的气泡"弹出窗口.
它可以正常工作,但我需要能够计算出它应该显示的位置(中间/底部).
代替:
<Path Stroke="Black" Fill="Black" Data="M 15 20 L 15 0 33 20" Margin="0 1 0 0"/>
我正在寻找(显然这是行不通的,但是它说明了我要完成的工作:
<Path Stroke="Black" Fill="Black" Data="M {TemplateBinding Left} 20 L 15 0 33 20"/>
可以用ValueConverter
完成吗?由于某种原因,我无法可视化解决方案.我也乐意接受其他选择.
感谢阅读,如果我能提供更多信息,请询问.
如果您想要一个可用于将字符串转换为路径数据的值转换器,则可以尝试使用 I have a It works fine but I need to be able to calculate where it should display (middle/ bottom). Instead of: I am looking for (obviously this won't work but it illustrates what I'm trying to accomplish: Can this be done with a Thanks for reading and if I can provide more info please just ask. If you want a value converter that you can use to convert a string into the path data, you might like to try the universal value converter I wrote a while back. Alternatively, to bind to a single property, you will have to expand your geometry by adding the various geometry objects into your XAML, rather than using the string shorthand. For example ...
这篇关于WPF-路径几何...是否有绑定数据属性的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!ControlTemplate
that serves as a "Bubble" popup on the AdornerLayer
of a given control. <Path Stroke="Black" Fill="Black" Data="M 15 20 L 15 0 33 20" Margin="0 1 0 0"/>
<Path Stroke="Black" Fill="Black" Data="M {TemplateBinding Left} 20 L 15 0 33 20"/>
ValueConverter
? I just can't visualize a solution for some reason. I'm also open to alternatives.<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>