我有一个线段列表,每个线段都包含一个点列表。包含在同一个画布上,我想显示每个线段并同时标记每个点的位置(即带椭圆)。我可以使用 ItemsControl 来显示段,但我不知道如何显示这些点。我开始实现从 Shape 派生的自定义控件,但必须有更简单的方法。在此先感谢您的帮助。
public class VesselAnatomy : IEnumerable, INotifyCollectionChanged
{
...
List<BaseVessel> _Segments;
...
}
public class BaseVessel : INotifyPropertyChanged
{
...
ObservableCollection<Point> _VesselPoints;
public ObservableCollection<Point> VesselPoints
{
get
{
return _VesselPoints;
}
}
...
}
public MainWindow()
{
...
VesselAnatomy Vessels = new VesselAnatomy();
...
MasterContainer.DataContext = Vessels;
...
}
<ItemsControl x:Name="VesselDisplay"
Height="750"
Width="750"
ItemsSource="{Binding}">
<Polyline Points="{Binding VesselPoints, Converter={StaticResource ObsListPointConverter}}"
Stroke="Red"
StrokeThickness="7">
<Polyline.ToolTip>
<ToolTip>
<TextBlock Text="{Binding Name}"/>
</ToolTip>
</Polyline.ToolTip>
</Polyline>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>