View Swapping Does Not Work in a SmartPartPlaceHolder

Topics: CAB & Smart Client Software Factory
Jul 26, 2007 at 6:32 AM
I have an application that has a dropdownlist whose selection change calls for a partial view change system response. Basically I have a citation type whose citation properties are different for each citation type. For example a publication citation is different than a website citation and different from a telephone conversation citation. So, in the parent view citation details view, I need to replace the existing citation properties view with one that has the appropriate citation property labels and textboxes with the necessary encapsulated rules and validation.

I thought it could be easily done by using a smartpartplaceholder and swapping views into the placeholder in response to a selection change from the user. When I test run the application, the default view in the smartpartplaceholder always remains in the placeholder and no swapping takes place; so, either my coding is flawed or the concept is flawed. Can someone provide guidance please?

To perform the swap, code is placed in the presenter to do the following (not exactly like this but very close):

// Grab the current view from the WorkItems collection after determining what type it is
CurrentViewType currView = base.WorkItem.Items.Get<CurrentViewType>("placeholderName")

// Remove the current view from the WorkItems collection

// Add the new view to the WorkItem with a reference for the destination smartpartplaceholder name

// Get a reference to the new view so I can work with it
NewViewType newView = base.WorkItem.SmartParts.Get<NewViewType>("placeholderName")

//update the databinding

There are no errors encountered in this process but the old view is never swapped with the new view. Should I be using a DeckWorkspace instead of a smartpartplaceholder? Is this even possible? Or is it just a repaint issue I have missed? I tried to hide and show and those don't work either.

Thanks in advance for your ideas on this.


Jul 26, 2007 at 1:09 PM
Hi ET,
We do some view swapping with a placeholder. The trick is to have the SmartpartPlaceHolder and update its Smartpart property.
Just change it to the new view and it will change.

I don't have the code at hand now, but it's really that simple.

Hope it helps,
Jul 26, 2007 at 2:51 PM
Thank you Ignacio. It is good to know that I don't have to refactor too much.