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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:49:12+00:00 2026-05-16T20:49:12+00:00

I’m using the MVVM pattern with Prism 2.0 framework and WPF. I’ve run into

  • 0

I’m using the MVVM pattern with Prism 2.0 framework and WPF. I’ve run into a problem with a modal Window and initializing a ViewModel using Events. In my module I have some code that creates an object which I then want to pass this into my ViewModel so that the View can bind to it’s properties.

Normally I’d use the EventAggregator to publish an event containing my object that can be be subscribed to in the ViewModel. However in this scenario I’m creating a new modal Window and therefore the ViewModel is not created in time to subscribe to the event before I can publish it. I’m trying to avoid passing the object in to the Window as DataContext or reverting to other mechanisms. Does anyone have a solution to get this working? Maybe some way of forcing the View to load before a call to ShowDialog or Show?

    var popup= new PopUpWindow();
    regionManager.RegisterViewWithRegion("MyRegion", typeof(MyView));
    eventAggregator.GetEvent<NotifyObjectEvent>().Publish(myObject);
    // ViewModel only created and subscribes to event when the line below is run
    popup.ShowDialog();

My hack to make this work is as follows, but I’m wondering if there’s a more elegant solution I’m missing?

    var popup= new PopUpWindow();
    regionManager.RegisterViewWithRegion("MyRegion", typeof(MyView));
    popup.Show();
    popup.Hide();
    eventAggregator.GetEvent<NotifyObjectEvent>().Publish(myObject);
    popup.ShowDialog();

Ok maybe I’ve figured it out, seems to work at least…

    var popup= new PopUpWindow();
    regionManager.RegisterViewWithRegion("MyRegion", typeof(MyView));
    RegionManager.SetRegionManager(popup, regionManager);
    regionManager.AddToRegion("MyRegion", typeof(MyView));
    eventAggregator.GetEvent<NotifyObjectEvent>().Publish(myObject);
    popup.ShowDialog();
  • 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-16T20:49:12+00:00Added an answer on May 16, 2026 at 8:49 pm

    You could use something similar to Ade Miller’s cached event aggregator. This link is from ’08, but it should still be useful: http://www.ademiller.com/blogs/tech/2008/11/adding-store-and-forward-support-to-the-prism-eventaggregator/

    The idea is to publish the event and in case there are no subscribers, store it until the first subscriber appears .

    I hope this helps.

    Thanks,
    Damian

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

Sidebar

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.