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

  • Home
  • SEARCH
  • 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 9310921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:14:06+00:00 2026-06-19T01:14:06+00:00

I hope a simple, albeit contrived question about the MVVM. My MainWindow has 1

  • 0

I hope a simple, albeit contrived question about the MVVM.

My MainWindow has 1 control – the ContentControl which displays one of only 2 views. I want to be able to switch between the 2 views via a button. The problem is, the buttons will be a control on each View. EG View1 has a button and View2 has a button. Only 1 view is every shown on the UI and by clicking the button the other view will be displayed. However, for this to work it will mean the ViewModel of the View will have to know about the MainWindow’s ViewModel in order to change the View. This seems wrong.

The issue may be my MainWindow ViewModel. One of the projects is public object View {get;set} and this is what binds to the MainWindows ContentControl. So, it’s this property which needs to be updated from the View’s viewmodel.

Does it go against the MVVM pattern if the View updates the MainWindow’s ViewModel?

  • 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-19T01:14:07+00:00Added an answer on June 19, 2026 at 1:14 am

    I am not sure if I totally understand your question but a good technique to communicate between viewmodels is either via the EventAggregator oder Messenger Pattern.
    These two implement pub/sub in a loosly coupled way.

    This is an example of MVVMLight Toolkit’s Messenger
    http://dotnet.dzone.com/articles/mvvm-light-whats-messenger

    This is an example of Prism’s EventAggregator to communictate between viemodels
    http://rachel53461.wordpress.com/2011/06/05/communication-between-viewmodels-with-mvvm/

    hope this helps..

    Edit: Ok, my answer is still valid. If you you use pub/sub like mentioned above you would tell view1 and view2 to send out a change view message for example and define a target (target could be view2 for example). Then you would subscribe in your MainViewModel to every change view message. And when a change view message arrives. The MainViewModel gets notified and executes an event and does not necessarily have to know who sent the message.

    And remember mvvm is only a pattern not a religion … just use the things that keeps you going and have the pattern in the back of your head =)…

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

Sidebar

Related Questions

Simple question I hope.... I have a Win Form with a Tab Control and
The question is ,I hope,simple for someone who knows about character encoding. This is
I hope this question has a simple answer. I am trying to add a
My question is a simple one to answer I hope. I am making a
Well, I have a simple question, at least I hope its simple. I was
I have what I hope is a simple question pertaining to the Atmel AVR
Simple enough question I hope. I am using the following type of code to
i have pretty simple simple question (i hope so). How do i change the
A relatively (I hope) simple jQuery question: I have a menu: <ul id=menu style=list-style:none>
Very simple question (I hope), does there exist a tool similar to phpMyAdmin when

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.