Question about the Hybrid example

Nov 30, 2010 at 9:52 PM

First of all, thanks for a very useful framework.

 

I am attempting to create an app based upon the hybrid example in the docs.

 

In this app, I would like to be able to 'close' the Settings view/view model.  In other words, when I press a button on the Settings view, I want the ActiveItem in the Shell view to no longer be the Settings view.

I placed the button on the Settings view and bound it to the TryClose method.  This does not give me the desired effect as it does exactly what it is suppose to do - close the view model.

However, this also removes the Settings view from the items list on the bottom of the Shell view.

 

So, how would I hide a view model instead of closing it, and leaving the area for the Shell view ActiveItem empty.

 

Thanks,

James

Coordinator
Nov 30, 2010 at 10:15 PM

from the settings vm, you could write a new method like this:

 

public void NoMoreSettings(){

   Parent.ActivateItem(null);

}

 

I *think* that will work.

Nov 30, 2010 at 10:28 PM

Thanks for the quick response.

 

Your suggestion takes me one step closer in that it deactivates the Settings view model.

However, the logic inside of CM if the target is null activates the 'previous' IWorkspace in the Items collection.  

In this case, it activates the Orders workspace.  (Not exactly what I'm looking for)

 

I've also tried to create a Blank view model and activate that.  The problem with this is that, upon activation, a button for the Blank view model is added to the buttons on the bottom of the window.

 

I'll gladly entertain any other suggestions.

 

Thanks,

James

Nov 30, 2010 at 10:57 PM

Came up with a solution.   It's a bit of a hack but it seems to work.

 

Working of the idea of a Blank view model, I added a ShowButton property to the IWorkspace interface.  

Then, in the Shell view, I bind the visibility of the button in the data template to the ShowButton property.

 

I then activate the BlankViewModel to 'hide' the other views.

 

Thanks for the input,

James

Coordinator
Dec 1, 2010 at 12:30 AM

In addition to Parent.ActivateItem(null), try overriding DetermineNextItemToActivate on the conductor and returning null from that. See if that works out.

Dec 1, 2010 at 2:41 PM

I knew that there had to be a better solution than the hack I did :)

 

The ActivateItem(null) and overriding DetermineNextItemToActivate and returning null worked great.

 

Thanks again for the responses.

James