This project is read-only.

conditional navigation

Oct 27, 2010 at 5:07 PM

Hi,

I am using Bxf with CSLA 4 and Silverlight 4.  One feature that I would like to include in my application is this: If a user has any unsaved changes on the screen (View) they are currently working on, and they attempt to navigate elsewhere, I would like to prompt them to see if they wish to continue navigating away from the current view.

I would like do this in a "generic" fashion, so that any new views created could achieve this with little or no code.

I'm guessing that somehow, I need to make my Main page aware of the IsDirty or IsSavable status of the current view's ViewModel?

Any help would be greatly appreciated.

Thanks,

Coordinator
Oct 27, 2010 at 5:34 PM

Not just the "current view", but the "current view within that region" right?

Yes, this is something the presenter code (typically the mainpage viewmodel) would handle.

For a region where this matters, the presenter should probably maintain a reference to the viewmodel it linked to the view that is currently displayed in that region.

On a subsequent request to display a view, it can then easily check the current viewmodel for that region to find out if navigation should be allowed. I'd define an interface your viewmodels can implement to make this easy/consistent. And I'd follow the basic models used by most smart client UI technologies, where the presenter calls a method on the viewmodel such as Closing(), allowing the viewmodel itself to decide whether to set e.Cancel to true - don't put the smarts in the presenter, put the smarts in the viewmodels.

Oct 27, 2010 at 5:51 PM

Yes, you are correct it's the "current view within that region".

This sounds like the solution I'm looking for.  I'll try to implement this pattern.  Thanks!