I got a List<Point>
containing about 500 points. Those points are supposed to be drawn as a path. But every once in a while I need to be able to switch to a "Points only" mode that shows not a continuous line, but just the points my line is based on.
If found a simple solution using an ItemsControl
which is not very performant:
<ItemsControl ItemsSource="{Binding Line}">
<ItemsControl.ItemContainerStyle>
<Style TargetType="FrameworkElement">
<Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="Point">
<Ellipse Fill="GreenYellow" Width="2" Height="2" Margin="-1,-1,1,1"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
When drawing my line using a Path
-object, the performance is much better (but it's a continous path and not single dots):
<Path Data="{Binding Path=Line, Converter={StaticResource ResourceKey=PointsToPath}}"
Stroke="GreenYellow"
StrokeThickness="2"/>
Is there a way to achieve the same (or at least similar) performance when just drawing the points of my line? The drawn dot's don't need to be in a certain shape or size for now...
If found this question: Most performant way to graph thousands of data points with WPF?, but there they are talking about up to 100 000 points - I hope to find a simpler way, since I'm dealing with a lot less points in my case.
I need to have those points drawn interactively as smooth as possible at at least 15 FPS