vrijdag 10 juli 2009

A viewmodel for the fluidkit transition control

I was trying to create a program that has several pages with only one page visible at a time. If you want to see another page you should press a button with the name of that page.
The first thing I tried was using a TabControl. The problem with the TabControl was that each time you left a page the page would be unloaded. This is not the behaviour I wanted. The pages should stay in memory even when they aren’t visible. I searched for a solution and found this blog entry that described an extension to the tabcontrol called TabControlEx. I tried it out and indeed the items in the tab stayed in memory, but I couldn’t get it to work the way I wanted it.
Then I remembered the fluidkit library created by Pavan Podila. This library has a class called TransitionPresenter that derives from ItemsControl. You can make a slideshow with the items you add to this control. The items you add stay in memory when they aren’t shown on screen. Because I always try to write my programs with the MVVM pattern I looked for a viewmodel for this class. I found a blog entry by Jeremy Alles who extended the TransitionPresenter and created a viewmodel for his newly created class. The strange thing was that his new class loaded the visible pages and unloaded the invisible pages. I tried to change this behaviour in his class but couldn’t figure out what happened and gave up.

Shout it kick it on DotNetKicks.com