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 6361135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:44:14+00:00 2026-05-24T23:44:14+00:00

My Main window defines the markup for the application, for this specific scenario lets

  • 0

My Main window defines the markup for the application, for this specific scenario lets say I have a grid with 2 columns.
First column will have navigation links, and second column will display the different views.
There are 2 views (and 2 viewmodels) defined in mainwindow xaml:

<Window.Resources>       
   <DataTemplate DataType="{x:Type vm:Window1ViewModel}">
       <vw:Window1View/>
   </DataTemplate>
   <DataTemplate DataType="{x:Type vm:Window2ViewModel}">
       <vw:Window2View/>
   </DataTemplate>      
</Window.Resources>

And in second grid column that displays the views i got :

<ContentControl  Content="{Binding Path=ViewModel}" HorizontalAlignment="Left">                    
</ContentControl>

Where ViewModel is a property that I set accordingly to a view(viewmodel) that i want to display.

Like :

ViewModel = new Window1ViewModel();
(datacontext of the mainwindowview is set to MainWindowViewModel)

So there is no problem to switch between views from the MainWindowViewModel.

My problem is how to switch within Window1ViewModel into Window1ViewMode2?

The various ViewModels don’t “know” about other ViewModels.
Only MainWindowViewModel knos about others…

How can I solve this?
Maybe I should define a custom Event (with parameter), MainWindowViewModel will subscribe and other viewmodels will trigger it and then MainWindowViewModel will switch to the needed view?

  • 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-05-24T23:44:14+00:00Added an answer on May 24, 2026 at 11:44 pm

    the solution you describe is one possibility. One other I can think of is using some kind of Navigation-Service (static class or interface you pass to all your child-Viewmodels) that do this kind of work.

    If your MainWindowViewModel creates all the others I would stick to the interface solution. You can for example let the MainWindowVM implement such a interface and inject it into all the child-vm on creation. This is much the same as your event-approach but instead of the childs-providing and the main having to subscribe you have the main give something … IMHO the better approach.

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

Sidebar

Related Questions

I have WPF application with one main window . In this window there are
I have an Air application with a main window. I would like to have
I have a WPF application which has a main window composed from several custom
I have a very simple Vaadin application. I want to inject the main window
I have a main window (#1) on my webpage from which I open a
Background: My application has a main window which contains a few smaller NSView objects,
I have a page viewer as main window showing an external page as we
i have a mvvm app that the main window is a tab control. i
I've an application that holds a main window with a list of items, and
I want to create an application which main window has canvas (or something where

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.