Canvas scrolling oddity

I noticed, in my app, that when scrolling a certain canvas with some controls on it, the controls when scrolled upwards were not disappearing when expected (at the top of the canvas), but continued to move up under/over some controls that lie higher up the window.

The canvas in question is in fact sitting on a rectangle (whose Top is higher that the canvas’s Top), which is there to provide a suitable background. Looking at it, I saw that it was the rectangle providing the scrolling visual boundary, not the canvas. And the reason for that seems to have been that the rectangle was the parent of the canvas. When I unparented the canvas, visibility of scrolled controls ceased at the canvas boundary, as desired, rather than the parent rectangle’s boundary.

Is this a bug or is it expected behaviour?

Sounds like a bug to me. You are scrolling the canvas not altering the value of top.

Sure. In the scrollbar’s ValueChanged event handler I call the scroll method on the canvas.

Sorry, that wasn’t meant to be a question. More a statement of why it was a bug. :slight_smile:

OK, I’ll see if I can work up a simple example.

Why don’t you draw the background right in the canvas?

I can’t remember.