Reputation: 645
I'm getting some performance issues with this code, where mousing over the canvas area is laggy if i leave in the canvases within the data template, but no lag if I take them out (but obviously the Canvas.Left bindings don't work so the ellipses are in the wrong place!) Is there a way to position these items without each one needing its own canvas?
<Canvas>
<ItemsControl ItemsSource="{Binding Path=SpatialData.TrainEvents.ArrDepEllipseOfLines}" Name="ctrlChartTrainEventsArrDep" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Canvas>
<Ellipse Width="{Binding EventShape.Width}" Height="{Binding EventShape.Height}" Stroke="{Binding Path=Stroke}" StrokeThickness="{Binding StrokeThickness}" Fill="{Binding Path=Fill}" Canvas.Left="{Binding CanvasPlacement.X}" Canvas.Top="{Binding CanvasPlacement.Y}" />
</Canvas>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Canvas>
Thanks very much, Becky
Upvotes: 0
Views: 607
Reputation: 209
Yes, you can remove the canvas in your ellipse. I think you'll find that your values for CanvasPlacement.X don't increment properly per ellipse and the effect your seeing is the fact that each element in your ItemsControl is actually placed in a StackPanel (the default behaviour and can be changed via the ItemsPanel property) which is then laying these out for you - most likely in a horizontal line.
Upvotes: 1