smooth scrolling in WP7: is it possible ?

Sep 12, 2012 at 9:09 AM
Edited Sep 12, 2012 at 9:20 AM

Hi, I'm trying to achieve smooth scrolling through a number of simple filled rectangles in WP7. The number of rects is principally unlimted (in the model), but the
number displayed in one "frame"/redraw is only about 30. 

while I'm experienceing a fast'n' fluid  scrolling in silverlight , the same procedure executed in WP7 results in a very poor performance, even in the emulator:
The updated bitmap gets not displayed with each update in the Image control.  It's all choppy and painfully slow when scrolling.

Maybe way I'm using it is not optimal:

=> Layout (the canvas inside the scrollviewer is only used to enable/detect the panning/scrolling):

<Grid Width=400 Height=700>
    <Canvas Width=10000 Height=10000/>
<Image IsHitTestVisible=false  />

=> Setup:

writeableBmp = BitmapFactory.New(400, 700);
image.Source = writeableBmp;

=> Redraw:

Then, on every scroll change (which is approx every 100 mesc) I'm drawing the rects that a currently visible in the viewport:


foreach (rect in rects){

if (IsVisible(rect)){




writeableBmp.Invalidate(); //btw: using (writeableBmp.GetBitmapContext(ReadWriteMode.ReadWrite)) does NOT update the bitmap in the image control

Any ideas how to optimize that ?


Sep 13, 2012 at 8:18 AM

You should wrap your calls in a BitmapContext. This will only invalidate all once.


using (writeableBmp.GetBitmapContext(ReadWriteMode.ReadWrite))

foreach (rect in rects)
if (IsVisible(rect))




Sep 13, 2012 at 12:13 PM
Edited Sep 13, 2012 at 12:27 PM

However, after the using block you have to add another " writeableBmp.Invalidate()" , otherwise the Image control will not display the updated bitmap during scrolling...

-->See the demo project  attached.

The second thing I've noticed is that there is a huge performance hit as soon as you do some text rendering:


textBlock.Text = "some text";
this.textBitmap = new WriteableBitmap(textBlock, null);

                new Rect(left, top, this.textBitmap.PixelWidth,  
                new Rect(0, 0, this.textBitmap.PixelWidth,      



Is there a faster way to render text with writeableBitmap?

Sep 15, 2012 at 3:28 PM

I switched over to XNA, as it is also supported in WP 8 and is much better suited for a scenario where you have to draw text frequently