MVVM using Page Navigation On Windows Mobile 7

Posted by anon on Stack Overflow See other posts from Stack Overflow or by anon
Published on 2010-05-09T10:19:32Z Indexed on 2010/05/09 10:28 UTC
Read the original article Hit count: 293

Filed under:
|
|
|

The Navigation framework in Windows Mobile 7 is a cut down version of what is in Silverlight. You can only navigate to a Uri and not pass in a view. Since the NavigationService is tied to the View, how do people get this to fit into MVVM. For example:

public class ViewModel : IViewModel
{
    private IUnityContainer container;
    private IView view;

    public ViewModel(IUnityContainer container, IView view)
    {
        this.container = container;
        this.view = view;
    }

    public ICommand GoToNextPageCommand { get { ... } }

    public IView { get { return this.view; } }

    public void GoToNextPage()
    {
        // What do I put here.
    }
}

public class View : PhoneApplicationPage, IView
{
    ...

    public void SetModel(IViewModel model) { ... }
}

I am using the Unity IOC container. I have to resolve my view model first and then use the View property to get hold of the view and then show it. However using the NavigationService, I have to pass in a view Uri. There is no way for me to create the view model first. Is there a way to get around this.

© Stack Overflow or respective owner

Related posts about mvvm

Related posts about windows-mobile