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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:32:40+00:00 2026-06-01T11:32:40+00:00

I use the Caliburn Micro framework. That doesn’t actually matter. The point is, that

  • 0

I use the Caliburn Micro framework. That doesn’t actually matter. The point is, that I publish an event in a view model, which contains the new view model to be shown in its event args. The event gets catched in the ShellViewModel (you could see it as the root view model), which actually activates the new view model.

So how could I pass the view model in my event args? Currently it looks like this:

// where it gets published; "AnotherViewModel" is the actual class
public void AMethod()
{
    var args = new ViewModelChangedEventArgs { ViewModelType = typeof(AnotherViewModel) };
    PublishEvent(args);
}

// event handler
public void Handle(ViewModelChangedEventArgs message)
{  
    if (message.ViewModelType == typeof(AnotherViewModel))
    {
        // activate AnotherViewModel
    }
    if (message.ViewModelType == typeof(FooViewModel))
    {
        // activate FooViewModel
    }
}

This method seems not very elegant to me. Do you have any better ideas?

  • 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-01T11:32:41+00:00Added an answer on June 1, 2026 at 11:32 am

    Overall solution is pretty well, you just passing a meta information in the event args which is enough to create a new ViewModel. Regarding ViewModel creating itself, this is a standard design problem which is solved by implementing Factory pattern. Basically you need a factory which is able creating concrete ViewModel by a type, so your handler code would be like below:

    public void Handle(ViewModelChangedEventArgs message)
    {  
        var viewModel = viewModelFactory.Create(typeof(AnotherViewModel));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with update listbox from view model class. I use Caliburn Micro
I develop wpf app with MVVM design. As MVVM framework I use Caliburn Micro.
I have this problem. I use caliburn micro in WPF. In view I have
I use Caliburn.Micro for my Silverlight application. I have a view/viewmodel to create a
Are there any sample applications avaliable that make use of both caliburn and prism?
I use Caliburn micro for my WPF Project. Static menus are easy to bind
I'm using Caliburn Micro for my project, and I decided to use Fluent Ribbon
i am trying to use Caliburn Micro in my windows phone 7 project. But
I'm learning about using Caliburn.Micro as a MVVM framework for a WPF application. In
I use caliburn micro and MEF in wpf and I have this problem. I

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.