Google Groups

ERROR (Designtime) Can't find BridgeViewModelBehavior ....

Gerhard Kreuzer Feb 10, 2011 11:50 PM
Posted in group: nRoute
I think, I didn't get this with checkout set 57081.
Next set I tried was 57381, and now it appears out of nothing. I just update the references, and didn't made any change to my app's code.
Rishi, maybe you can tell us shortly, which changes were made between this two versions, especially add/change references, maybe we can solve it quickly.
With best regards

Von: [] Im Auftrag von Adrian Hara
Gesendet: Donnerstag, 10. Februar 2011 08:43
Betreff: RE: [nRoute] NEW FEATURE: Application Tombstoning and Cascading State Management

Hi Gerhard,


Read this: 


Tombstoning is a windows phone 7 concept whereby an application is closed by the OS under certain conditions, but gets a chance to save its state so it can be resumed from the same “screen” later. I guess a similar term for “tombstoned” would be “suspended”…





Freundliche Grüsse / Best regards

Adrian Hara
Cloud Developer

coresystems ag
Villa im Park | Dorfstrasse 69
5210 Windisch | Switzerland

Phone +41 56 500 22 22
Fax +41 56 444 20 50
Infoline +41 848 088 088
follow us on

Visit us at CeBIT:
SAP Partner Booth: Hall 5, Booth A18
Cloud Computing: Hall 4, Booth A58
OS X Business Park: Hall 2, Booth A20
Microsoft Booth: Hall 4, Booth P47

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and / or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

From: [] On Behalf Of Gerhard Kreuzer
Sent: Wednesday, February 09, 2011 10:01 PM
Subject: AW: [nRoute] NEW FEATURE: Application Tombstoning and Cascading State Management


Hi Rishi,


cant find 'tomb-stoning' at, so what is another term for that?






Von: [] Im Auftrag von Rishi Oberoi
Gesendet: Samstag, 05. Februar 2011 17:32
Betreff: [nRoute] NEW FEATURE: Application Tombstoning and Cascading State Management

Recently I wrote about a new feature that allows navigation-containers to save and restore view state (from the View) in addition to the logical state (from the ViewModel). Now, I've extended the use of the view-state management functionality to allow for dehydrating and hydrating of the navigation-container's state. What does that mean, it means navigation-container's internal state (which contains the navigation history, navigated urls info, visual-state, logical-state etc) can be extracted and inserted back. Furthermore, this state can also be serialized and de-serialized to allow for persisted tomb-stoning for either the full application or part of the application.  


In terms of the implementation, all the built-in navigation containers now implement ISupportNavigationViewState, which again looks like:

    public interface ISupportNavigationViewState 
        void RestoreState(ParametersCollection state);

        ParametersCollection SaveState();

So, to get the state it's just a matter of calling SaveState, and equally use RestoreState method to restore the state - nothing special there. The interesting thing is that you can take this state are serialize it and derserialize it - and it would basically restore everything from the page's View/ViewModel-state, back/forward navigation history, etc etc. However, you need to be mindful that anything you've stored in the state (either in the View or ViewModel) needs to be serializable, and the serializer needs to be made aware of it. For example, in one the sample in the repository, I store a "Person" object in my ViewModel's state - and so in addition to the types the container uses the person type must be made known to the serializer (note I'm working a some infrastructure to make this auto-discoverable):

    var _state = ((ISupportNavigationViewState);
    var _memStream = new MemoryStream();
    var _serializer = new XmlSerializer(typeof(ParametersCollection), new Type[] { typeof(Parameter), typeof(PageContentState), 
        typeof(PageContentState[]), typeof(Object[]), typeof(Object[][])
typeof(Person) });    // note the custom type - Person 
    _serializer.Serialize(_memStream, _state);

    PresistState(Encoding.UTF8.GetString(_memStream.GetBuffer(), 0, Convert.ToInt32(_memStream.Length)));

The same logic stands when deserializing. Also, if you are going to use this capability put some thought around what you store in the state especially with reference types, and pls don't start storing control instances because you'll start leaking memory by the dozen. 


The second use of having the navigation-containers be able to save and re-store state is to allow for cascading state management. In any complex application you'll often see that you have a shell-container that hosts the top-level content, and then the top-level content UIs are themselves composed of many sub-sections again using navigation-containers - a simple example would be where you have a side-panel. Now the problem earlier with such a setup was that when you navigated at the top-level the top-level content's ViewModel would persist its state but all the View/ViewModel state of the side-panel/inner-sections would be completely lost (without some manual intervention). However, now with the addition of View state and Navigation-Container state capabilities, what you can do is: save the inner-container's state from within the View when the View's SaveState method is called and vice-versa when restoring. In the example below, I have a top level page that hosts two sub-containers - and when saving/restoring the View's state I can save/restore the inner container's state:

    public partial class Shell : UserControlISupportNavigationViewState
        public void RestoreState(nRoute.Components.ParametersCollection state)
            var _leftState = state.GetValueOrDefault("LEFT"default(ParametersCollection));
            var _rightState = state.GetValueOrDefault("RIGHT"default(ParametersCollection));
            if (_leftState != null) ((ISupportNavigationViewState)leftContainer).RestoreState(_leftState);
            if (_rightState != null) ((ISupportNavigationViewState)rightContainer).RestoreState(_rightState);

        public nRoute.Components.ParametersCollection SaveState()
            return new ParametersCollection()
                new Parameter("LEFT", ((ISupportNavigationViewState)leftContainer).SaveState()),
                new Parameter("RIGHT", ((ISupportNavigationViewState)rightContainer).SaveState()),

And if you've set-it-up right, then this would cascade to n-levels. Also, you can also implement this functionality with other sorts of controls - for example, with a Tab-Control you could possibly get a listing of all the tabs open and serialize/derserialize the navigation-containers state within each tab along with a listing of the tabs. 


I think this has a lot of uses and expands the horizons of what applications can do - for example, you can serialize the state to a db and when the user logs in, possibly on another computer, he/she can resume where they left as if nothing changed. Further, I'll be integrating this with WP7's tomb-stoning infrastructure - so if you use nRoute, you'll get tomb-stoning feature for free.


Lastly, I'd appreciate if anyone can test this with some meaty examples, and let me know either about any edge-cases I've missed or issues otherwise.