Wintellect Blogs

Page-Turn Framework Updated for Silverlight 2

29 Oct , 2008  

I just returned home from the PDC after a marvelous few days in sunny L.A. Sunday’s Silverlight precon was a blast, and if you attended, I hope you felt it was worth your time. I could have easily filled out two more days with Silverlight fun and games, but I tried to hit the high points in the time we had together.

I spent my time on the airplane to and from L.A. updating my page-turn framework for Silverlight 2. The original framework utilized Silverlight 1.0 and was introduced in the May 2008 issue of MSDN Magazine. The new version features the same basic API with a few tweaks and additions. For example, the PageTurn class now fires a PageTurned event each time a page turn is complete, making it easy to update the UI around the page-turn canvas each time the user flips a page. Here’s a sample built around the new framework:

PageTurnDemo 

You can download the sample code here, or view the app online here. The page-turn framework is implemented in PageTurn.cs, and you can see how to use the framework by perusing Page.xaml and Page.xaml.cs. The XAML structure is the same as described in the aforementioned MSDN Magazine article.

I still need to do some cleaning-up in the code and would also like to add a few more features. But since the framework’s in decent shape as is, and since I have promised publicly to update it for Silverlight 2, I didn’t want to wait any longer to push the bits out there. If you have comments, questions, or suggestions (or, heaven forbid, find any bugs), be sure to let me know.


  • http://geekswithblogs.net/WynApseTechnicalMusings/archive/2008/10/29/126378.aspx Anonymous

    In this issue: Jeff Handley, David Anson, Jafar Husain, Justin Angel, Beatriz Stollnitz, Scott Barnes

  • http://www.SilverlightArtist.com Anonymous

    Very nice Jeff – thank you very much for sharing this.

    David Roh

  • Anonymous

    Hello Jeff: Great precon session; I actually liked it better than PDC itself. Anyway, I cannot for the life of me remember the uri you gave for your web demos (something like webdemo1.aspx). Can you pass it along? Thanks again for the great session… -Dan

  • jprosise

    Dan, you can download my PDC demos from http://www.wintellect.com/Downloads/PDC_2008_Demos.zip.

  • Anonymous

    Hi
    The demo I saw on was super. I downloaded it, unzipped it and tried to run it, but it never finishes loading.

  • http://steven.james@1800thenerd.com Anonymous

    An ability to print a page or a section of pages.
    An ability to search to the first page with a word in it.
    An ability to have a Table of Contents.

  • http://blogs.msdn.com/renedepaula/archive/2009/02/05/virando-a-p-gina-com-silverlight-2-use-vontade.aspx Anonymous

    já havia um “page turner” em Silverlight 1.0, mas com a versão 2.0 o desempenho ficou ainda melhor.  

  • Anonymous

    Is it possible to modify the GoToSpread-method so that it turns the page in the same nice way, that it does when I do it manually?

  • jprosise

    Yes, although it’ll require some work. I intend to update the framework to take advantage of some SL3 features such as animation easing. Maybe when I update it I can add an “automatic paging” feature.

  • jprosise

    Version 2 of the framework (the C# version) has a GoToSpread method for doing exactly that. You could either use version 2 or port that method to JavaScript. You really should use v2; it’s nicer and cleaner!

  • Anonymous

    I blame it all on the cold medicine. Took a long look at the code again and figured out my error. So I’ve got it working now.

    Does version 2 work on Macs? I have downloaded it and have it running, but when I look thru the directories I see a dll. The mac I can test on has an older version of OS 10 that won’t load silverlight. Still waiting to use somebody’s newer mac for testing version 2.

  • Anonymous

    This is a great framework, thanks for that.

    Little optimization if you have a lot of pages:

    If you have a lot of pages (>40 double pages) the cpu uses is quite high on page turn. I have changed the framework so that only the visible pages and one before and after are visible. The other pages are always collapsed. The cpu usage is then a lot better.

    So if you plan to use this framewrok for a lot of pages this may help you.