I am working on implementing an ISrollInfo interface for a custom control. Simply put, I have a label in my custom control under a Canvas. I would like the label to “stay in place” when my custom control is scrolled. That is, the label needs to be always visible no matter the scrolling offset.
Now, to as a test I added this sample code
protected override Size MeasureOverride(Size constraint)
{
return new Size(1000, 50);
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
double x = 50;
double y = 50;
label1.Arrange(new Rect(new Point(x, y), new Size(1000, 50)));
return arrangeBounds;
}
When I test the control (my control is put inside a ScrollViewer), the label is hidden (before and after I use the scrollbar). If I remove the override for ArrangeOverride, the label appears and scrolls around as I use the scrollbar.
Any ideas as to what I am missing?
Found it, my ArrangeOverride is on the UserControl, where I specifically only arrange the label, the canvas doesn’t get arranged (i.e postion and size is not set). Now, since the label is in the canvas, you can’t see it.