[英]WPF polyline - how to highlight points?
您好,我有一个关于 WPF 中折线的问题。 如何突出折线中的点,例如线是红色的,但mypolyline.Points中的点是蓝色的?
Polyline
不能开箱即用,因为它仅呈现为连接线段的集合。
但是,您可以添加一个ItemsControl
来呈现如下所示的点。 它使用零长度的Line
元素,但使用圆形开始和结束帽来显示一个点。
<Polyline x:Name="polyline" Points="10,10 50,50 90,10" Stroke="Red"/>
<ItemsControl ItemsSource="{Binding Points, ElementName=polyline}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Line Stroke="Blue" StrokeThickness="5"
StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.