繁体   English   中英

WPF 折线 - 如何突出显示点?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM