Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:10:59+00:00 2026-06-05T16:10:59+00:00

I just started developing my brand new windows 8 application last week using mvvm

  • 0

I just started developing my brand new windows 8 application last week using mvvm light.I am familiar with mvvmlight WP7 navigation. How i can achieve the same in windows 8. Can any one suggest a better method to achieve the same in windows 8. I found a solution, where we override onnavigated events in vm and handle navigate to other page. But i think that method is obsolete. Any one please guide me with the proper implementation. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:11:02+00:00Added an answer on June 5, 2026 at 4:11 pm

    I understand this is not the exact answer you may be looking for, but this may give you some ideas to explore.

    In my case, I’m not using MVVMLight – but my own simple MVVM implementation. I use the BindableBase class (which comes with the default VS 2012 RC templates) for property notifications. I imagine, you could use MVVMLight to give you some of the infrastructure, which you can complement with something like the below.

    For navigation, I define an interface that looks like:

    public interface INavigationService
    {
        void Navigate(Type type);
        void Navigate(Type type, object parameter);
        void EnsureNavigated(Type pageType, object parameter);
    
        bool CanGoBack { get; }
        bool CanGoForward { get; }
        void GoBack();
        void GoForward(); 
    
        IView CurrentView { get; }
    }
    

    And implement it as follows:

    using System;
    using System.Collections.Generic;
    using System.Threading.Tasks;
    using Windows.UI.Xaml.Controls;
    
    public class NavigationService : INavigationService
    {
        private readonly Frame _frame;
    
        public NavigationService(Frame frame)
        {
            _frame = frame;
            _frame.Navigated += OnFrameNavigated;
        }
    
        private void OnFrameNavigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            var view = e.Content as IView;
            if (view == null)
                return;
    
            var navMsg = new NavigationMessage()
            {
                Sender = this,
                NewView = view,
                Parameter = e.Parameter,
                NavigationMode = (int)e.NavigationMode
            };
    
            EventManager.Current.Publish(navMsg);
    
            //Anything that the parent needs to be notified should happen in of after this method
            var viewModel = view.ViewModel;
            if (viewModel != null)
                viewModel.Initialise(e.Parameter);
        }
    
        public void Navigate(Type pageType)
        {
            DisposePreviousView();
            _frame.Navigate(pageType);
        }
    
        public void Navigate(Type pageType, object parameter)
        {
            DisposePreviousView();
            _frame.Navigate(pageType, parameter);
        }
    
        private void DisposePreviousView()
        {
            var currentView = this.CurrentView;
            var currentViewDisposable = currentView as IDisposable;
            if (currentViewDisposable != null)
            {
                currentViewDisposable.Dispose();
                currentViewDisposable = null;
            } //view model is disposed in the view implementation
        }
    
        public void EnsureNavigated(Type pageType, object parameter)
        {
            var currentView = this.CurrentView;
            if (currentView == null || currentView.GetType() != pageType)
            {
                Navigate(pageType, parameter);
            }
        }
    
        public IView CurrentView
        {
            get { return _frame.Content as IView; }
        }
    
    
        public bool CanGoBack
        {
            get { return _frame != null && _frame.CanGoBack; }
        }
    
        public void GoBack()
        {
            // Use the navigation frame to return to the previous page
            if (_frame != null && _frame.CanGoBack) _frame.GoBack();
        }
    
        public bool CanGoForward
        {
            get { return _frame != null && _frame.CanGoForward; }
        }
    
        public void GoForward()
        {
            // Use the navigation frame to return to the previous page
            if (_frame != null && _frame.CanGoForward) _frame.GoForward();
        }
    
    }
    

    IView:

    public interface IView : IDisposable
    {
        IViewModel ViewModel { get; }
        void Refresh();
    }
    

    IViewModel:

    public interface IViewModel : INotifyPropertyChanged, IDisposable
    {
        void Initialise(object parameter);
        string ViewTitle { get; }
        void Refresh();
    }
    

    Finally, in the XAML page, define a Frame element:

    <Frame x:Name="ContentFrame" />
    

    And in the code-behind of the page: (this in the only ugly part in my opinion – but its hopefully not too bad):

    var _navigationService = new NavigationService(this.ContentFrame);
    

    You can now pass the _navigationService to the viewmodel. In my case I create the viewmodel in the code-behind of the page:

    public HomePage()
    {
        this.InitializeComponent();
    
        var _navigationService = NavigationService.GetFor(this.ContentFrame);
    
        DataContext = new HomePageViewModel(_navigationService);
    
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started developing library management system using django. I'm new to Django, so
I just started developing a web application using struts 1.3.10 tiles framework. There is
I have just started developing a full-web application by using the ASP .NET MVC
I've just started developing a small C++ program using GraphViz's graph library and noticed
I just started practicing TDD in my projects. I'm developing a project now using
Just today I've started using Drupal for a site I'm designing/developing. For my own
Just started developing a project using NHibernate and Fluent NHibernate for the mapping and
I just started developing a new website and I have some questions. You can
I just started developing my new project in Yii, I am new to Yii
I just started using a javascript engine from Microsoft(of IE9?) for developing both desktop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.