If there are tens of thousands of labels in the Canvas, I want to change only the position of the labels when zooming, not the length and width of the labels. Is it possible to do that?
I tried to change the position of the labels by traversing them, but when the number of labels is too high it causes the zoom to lag.
Here is the code for iterating the position:
public void UpdateVisibleControls(Rect visibleRect, Size widgetSize)
{
for (int i = Children.Count - 1; i >= 0; i--)
{
if (Children[i] is IMarker marker)
{
Rect elementRect = new Rect(marker.ActualX, marker.ActualY, marker.MarkerWidth, marker.MarkerHeight);
if (!elementRect.IntersectsWith(visibleRect))
{
marker.X = -100;
marker.Y = -100;
SetPosition(marker);
}
else
{
marker.CalculatePosition(visibleRect, widgetSize);
SetPosition(marker);
}
}
}
}
New contributor
Chaoping Luo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.