How to merge SL Navigation with MvvM - Bxf MainContent Presenter

How to merge SL Navigation with MvvM - Bxf MainContent Presenter

Old forum URL:

Jav posted on Tuesday, August 10, 2010

My App is structured almost exactly like the very first SlDemo from the Mvvm Videos, i.e., a central are for main navigable content with ouside fixed areas for buttons etc.  I use SL Navigation.

I hear in the video that the main reason to use Mvvm pattern is to make testing easier and to eliminate code behind - and I buy that.  My venture into MvvM, however, was the result of Detour sign on the highway that said:  DataProviders permanatly closed - Use MvvM - Turn Left Here.

I have been thankful for the ViewModel availability and have been speeding along, displaying contect in a Frame using Silverlight Navigation system, and everything's been sweet. 

Now in the MvvM videos, all I hear about is the MainContent Presenter and a View Changer, with no mention of Csla Navigation which was there  at one time, nor of the SL navigation which essentially replaced Csla navigation.  So before I do something stupid and start dismantling my SL Navigation, I have some questions.

1.  Is this meant to be a replacement for the existing Navigation System, and would it present comparable functionality like pressing the Back key to go to a previous view, or seeing a list of all previous views in a dropdown list from Browser's Backup funtionality - and whatever else may be there.

2. If I want to stay with SL navigation, what are the caveats in creating VM's for all child objects (and collections of child objects) of my object graph, many of them are lazy-loaded and what would be the best place to plug in that functionality, i.e., creation of the VM for the newly created collection or the object.  I did study the code in SlDemo videos but the examples appear to tie it into Shell.Instance.ShowView()?

3.  Can I use the Bxf's Status and Error display functionalty while continuing to use SL navigation.  In fact the only status I need to display outside the navigation frame is the IsValid status of each object in the object graph - and that is on the wish list.

Thank you.


RockfordLhotka replied on Tuesday, August 10, 2010

This thread should really take place on - it has essentially nothing to do with CSLA, and everything to do with Bxf.

Bxf is, fist and foremost, a teaching tool intended to distill MVVM to the smallest possible implementation. So it doesn't integrate with the back button or anything like that, no.

Of course Bxf is an open source framework - I'm very happy to have people contribute to the project. I don't want it to get big or complex - no sense competing with pre-existing MVVM frameworks out there - but there's certainly room to enhance the framework while keeping it extremely lightweight and simple.

All that said, I suspect it can work with SL navigation with little or no change.

Bxf requires that you implement a "presenter" that is responsible for handling the three events (to show a view, error and status). You can implement those three behaviors any way you choose - including having OnShowView call SL navigation to navigate to a new view.

On the flip side, SL navigation (I think) has ways for you to run initialization code as a new page is initialized. Sadly I haven't had time to dig into SL navigation as much as I'd like... But this is one area where Bxf might need a little enhancement - since it may not be possible for this navigation initialization code to call Bxf to hook up the viewmodel to the view.

I assume SL navigation will create the view, and thus any CollectionViewSource resources, etc. Something then needs to create the viewmodel (based on the query parameter data) and hook up the viewmodel to the view.

However, InitializeBindingResource() is a protected method, so it might be as simple as creating a custom subclass of Shell that exposes a method to create an IView with a pre-existing view (the one created by SL navigation) and the viewmodel you create based on the query parameters - and then this Shell subclass would invoke InitializeBindingResource() to connect the viewmodel to the view.

RockfordLhotka replied on Tuesday, August 10, 2010

In fact, I created a thread on codeplex for this

Jav replied on Tuesday, August 10, 2010

yes, I saw that.  In fact you physically lifted me outa' here and put me there Big Smile
I appreciated that, and have already started my pestering over yonder.

Nice to know that mine is the first message in that  forum - yeah
(Note to self: must tell grand kids some day)


Copyright (c) Marimer LLC