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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:08:28+00:00 2026-05-23T20:08:28+00:00

I have a page where you basically select a set of options (configuration), and

  • 0

I have a page where you basically select a set of options (configuration), and then you go to a next page, where you do some stuff
Using the MVVM Light toolkit, I have a viewmodel that binds to the view of the first page. when the user hits a button, it redirects to another view, which would be the 2nd page
i.e.:

Page2Command = new DelegateCommand((obj) => 
    Messenger.Default.Send<Uri>(new Uri("/DoStuffView.xaml", UriKind.Relative), 
                                Common.CommonResources.GoToDoStuffRequest)) });

The problem is, the viewmodel for the 2nd view (the way that I see it) has a couple of parameters in the constructor, which are basically the dependencies on the configuration that was set on the first page.

i.e. :

public DoStuffViewModel(ICollection<Note> availableNotes, SoundMappers soundType)
{
}

The problem lies here.. How can I instantiate the viewmodel with this data that was dynamically selected by the user on the 1st page?.
I can’t use the ViewModelLocator pattern that MVVM light provides, since those viewmodels don’t have any dependencies, they are just by themselves (or they can retrieve data from a db, file or whatever, but they don’t have any dynamic input data). I could do it through the view’s constructor, instantiate there the viewmodel, and assign to the view’s DataSource the newly created viewmodel, but I think that’s not very nice to do.
suggestions?

  • 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-23T20:08:29+00:00Added an answer on May 23, 2026 at 8:08 pm

    As I see you send messsage using Messenger class so you are familiar with messaging in MVVM light. You have to define your own message type that should accept your parameters from page 1:

        public class Page2ViewModelCreateMessage : MessageBase
    {
        public ICollection<Note> AvailableNotes{get;set;}
        public SoundMappers SoundType{get;set;}
    
        public Page2ViewModelCreateMessage ()
        {
    
        }
    
        public Page2ViewModelCreateMessage(ICollection<Note> availableNotes, SoundMappers soundType)
        {
            this.AvailableNotes = availableNotes;
            this.SoundType = soundType;
        }
    }
    

    You have to send an Page2ViewModelCreateMessage instance with you parameters and send it on navigating:

    var message = new Page2ViewModelCreateMessage(myAvailableNotes, mySoundType)
    Messenger.Default.Send(message);
    

    On Page2 you have to register for recieving message of type Page2ViewModelCreateMessage:

            Messenger.Default.Register<Page2ViewModelCreateMessage>(this, OnPage2ViewModelCreateMessage);
        ..
        public void OnPage2ViewModelCreateMessage(Page2ViewModelCreateMessage message)
        {
            var page2ViewModel = new Page2ViewModel(messsage.AvailableNotes, message.SoundType);
        }   
    

    As you can see I have replace your DoStuffViewModel with Page2ViewModel to be more clear.

    I hope this will help you.

    NOTE:I dont guarantee that code will work as its written in notepad.

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

Sidebar

Related Questions

I have a page which basically allows an admin user to create manager user
I have a page where I basically want an element to 'blink' for a
I have a page that will basically be used to concatenate a bunch of
I have this page which has three peson searchs on them. Basically it's a
Basically I have a single page on my site that I want any php
Basically I have a single page site that scrolls when the user clicks on
I have a JSF page that is included in other JSF pages (basically a
I have a one-page OpenOffice document which is a POD template. Basically, I use
Basically I have a series of projects displayed on the page. Each project consists
In this html I basically have a sidebar-div and a page-div with the header,

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.