Silverlight Scrolling Region Example

I got a request today to explain how the scrolling region works that I use on my Silverlight page.  Instead of using a complex example (like showing you that code) I decided to create a really simple example.

The trick to creating a scrolling region is to create a Canvas with a Clipping Path (you can do this with Expression and I have a video that shows how here). So the Canvas with a clipping region essentially is a window to a larger set of content.  For example here is a simple canvas with a clipping mask.  The arrows on the left show the size of the clipping region (the window into the the object) and the arrows on the right show the full size of the object itself:

To create a scrollable region, you wil just move the elements inside the clipping region canvas.  For example:

<Canvas Name="theClipRegion" Clip="..." ...>
  <Canvas Name="theCanvas">
    ... Your Content
  </Canvas>
</Canvas>

In this example, when you click on the arrows it simply adds or subtracts 10 from the Canvas.Top of the "theCanvas" to move it within the Clipped Canvas.  You don't need to move the clipping region because that's a window on the content within so you don't move the window, but the content inside.

You can get fancy and use an animation to do so (like I did for the Silverlight page) or something simple like this.  It works vertically or horizontally.  Grab the code and check it out!

Comments:

Gravatar

it's very good.
"scrollable" is a bisic skill for presentation.
Does anyone know how to add a "scrollable" property to a full Silverlight page like a html page does ?

Gravatar

I don't believe there is a good way to do this. You could set the Silverlight's DIV to overflow but I am not sure that will work

Gravatar

See the new Scrolling Silverlight sample at:

http://adoguy.com/2007/09/04/CSS_Scrolling_and_Silverlight.aspx

Gravatar

great article.

wish it had the code for the animation too, but i'll try to figure that one out myself

Gravatar

Thanks for the example, it helps me alot

Gravatar

This sounds like just what I am looking for. Is the code still available for this? This link no longer works,

http://adoguy.com/downloads/scrollingregionsample.zip

Gravatar

When moving my server recently I forgot to move the download directory. It should work now. Thanks for the heads up.

Gravatar

It is indeed a very helpful article.I tried doing as suggested and got the desired result. Thank You.


 



 
Save Cancel