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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:51:29+00:00 2026-05-17T18:51:29+00:00

A common approach for communication between 2 ViewModels is this: MVVM- View Model-View Model

  • 0

A common approach for communication between 2 ViewModels is this: MVVM- View Model-View Model Communications

The Mediator pattern or a Messenger class. But what about 6 ViewModels in one Window?

  1. NewSchoolclassUserControl
  2. NewPupilUserControl
  3. SchoolclassListUserControl
  4. PupilListUserControl
  5. PupilsDetailUserControl
  6. AdministrationButtonBarUserControl
    (having buttons executing commands)

All this is in ONE Window. Do “you” really tell me now I have to setup a Messenger for those 6 Views and their Viewodels? That would be terrible…

6 UserControls in one Window, not even a big enterprise app has more UserControls in a window, so whats an accepted/best practice in that case?

I would be interested in someones opinion having experience with big mvvm applications ๐Ÿ™‚

Some of those UserControl+ViewModels I would like to reuse at other places of my application. So put all in one UserControl is not that what I really want.

UPDATE: for the blind meise ๐Ÿ˜‰

private DateTime _selectedDate;
        public DateTime SelectedDate
        {
            get { return _selectedDate; }
            set
            {
                if (_selectedDate == value)
                    return;

                _selectedDate = value;
                this.RaisePropertyChanged("SelectedDate");


                ObservableCollection<Period> periods = _lessonplannerRepo.GetLessonDayByDate(SelectedDate);

                _periodListViewModel = new ObservableCollection<PeriodViewModel>();

                foreach (Period period in periods)
                {
                    PeriodViewModel periodViewModel = new PeriodViewModel(period);

                    foreach (DocumentListViewModel documentListViewModel in periodViewModel.DocumentViewModelList)
                    {
                        documentListViewModel.DeleteDocumentDelegate += new Action<List<Document>>(OnDeleteDocument);
                        documentListViewModel.AddDocumentDelegate += new Action(OnAddDocument);
                        documentListViewModel.OpenDocumentDelegate += new Action<Document>(OnOpenDocument);
                    }

                    _periodListViewModel.Add(periodViewModel);                    

                } 
            }
        }

@blindmeise

This ViewModel is datatemplated actually to a DataGrid. The Periods are the Rows. Each Row has a Column called Documents. I have a PeriodListViewModel 1 : N DocumentListViewModel.

The DocumentListViewModel is datatemplated with a UserControl containing a ListBox and below some buttons add/del/save/open etc…

A DocumentListViewModel has Commands and Action delegates executed in the “LessonController” so every action on a Document like add,del etc… can be done on the SelectedPeriodViewModel declared in the LessonController.

The above code just loads new data from database when the user changes the date in the datepicker.

Do you need more code or what do you say about my approach? I am eager to learn and I am glad about every critics!

  • 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-17T18:51:29+00:00Added an answer on May 17, 2026 at 6:51 pm

    if you have 6 or 1000 loosly coupled viewmodels which should communicate with each other, then you should use the messenger/mediator. it has nothing to do with usercontrols at all.

    if your viewmodels reference to each other then you have no need for a messenger, but its no more loosly coupled then ๐Ÿ™‚

    edit:
    its really hard to say what can you to better, cause i dont know what do you want to achieve with your app and your appdesign ๐Ÿ™‚ in general it depends on how you specify the tasks for your viewmodels and how do you want to couple these viewmodels. maybe you should check some sample projects from over the www ๐Ÿ™‚ there are a lot mvvm implementation which vary a lot but gives a better understanding on the mvvm pattern(pattern!! not rule!! ;))

    imagin you have a viewmodel which do nothing then select a date. this would be a simple loosly coupled vm. all you can do now is when a new date is selected, send a message through a messenger.

    public DateTime SelectedDate
    {
        get { return _selectedDate; }
        set
        {
             if (_selectedDate == value)
                 return;
    
              _selectedDate = value;
              this.RaisePropertyChanged("SelectedDate");
    
              this.messenger.Notify("SelectedDateChanged", this.SelectedDate)
         }
     }
    

    now all other loosly coupled viewmodels could register to the mediator and the “SelectedDateChanged” message and do what the want to do when a date changed.
    this maybe does not fit in your design, but should give you an idea on the messenger pattern.

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

Sidebar

Related Questions

A common pattern in C++ is to create a class that wraps a lock
Common question but I could use an english explanation. Is it like Java where
A common approach to data modelling is to use a data modelling tool (e.g.
I have what seems to be a fairly common inter-process communication requirement - a
What is the common approach to save user's inputed data: 1. Overriding onPause() method
A common task in programs I've been working on lately is modifying a text
With common lisp and I am assuming the introspection properties. How can I add
A common argument against using .NET for high volume, transactional enterprise systems is that
A common mistake when configuring the compilation/linking/etc. settings in VC++ 2008 is to set
A common web UI design is to display a sortable grid (GridView, ListView, DataGrid)

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.