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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:13+00:00 2026-05-27T22:46:13+00:00

When developping rather large applications using Prism and MEF/Unity I always reach a point

  • 0

When developping rather large applications using Prism and MEF/Unity I always reach a point where I should choose between using events, a service or maybe both. And I cannot decide what’s most usable. Maybe something is wrong with my architecture (as in this decision shouldn’t have to be made in the first place) but I don’t see what.

Here’s a typical example: my application has a main window and a lot of slave windows that are created on demand by modules or user actions. The application decides what a slave window’s chrome looks and behaves like, remembers window placement etc while the content itself is created somewhere in the modules. There are also a lot of user actions resulting in hiding/showing/bringing to front of windows. To achieve all this, I currently have a WindowManager service that listens to CreateWindow/SetWindowState/.. events.

This has benefits:

  • classes using this only know about IEventAggregator (which they already use most of the time anyway for other events) and the events consumed by WindowManager, not WindowManager itself
  • classes like ViewModels don’t deal with windows directly. Instead they refer to them by their title or id and small event classes that encapsulate just what’s needed.
  • no need for a seperate IWindowManager interface just for the purpose of mocking it in a test

And withdrawals:

  • WindowManager could be used perfectly standalone, but now it needs to subscribe for events. Or probably better, some other class has to take care of that.
  • extending it to show a modal dialog is somewhat tricky: if a VM fires an event to show a dialog, it’s of utter importance that the Publish call only returns after the dialog was closed
  • WindowManager is available as a service and it’s in the CompositionContainer, why not use it as such anyway?

Using the service directly just shifts benefits/withdrawals around and there doesn’t seem to be a clear winner.

Question: what would you use as guidance rules to pick one or the other, or would you rather always pick just one, or both? Is there something particularly wrong in my application design that I have to make this decision?

  • 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-27T22:46:14+00:00Added an answer on May 27, 2026 at 10:46 pm

    Events and services are used for different things. You don’t have to choose between them, you can use them for different purposes. You would typically use event to notify listeners that something has happened. Example: users changes the font size in the application settings. You would send event to all listeners (e.g. viewmodels) so that the views update. Usually event is kind of thing for which you don’t get a response (although you could attach e.g. callback function/action that the event listener would call).

    What if your viewmodel needs to open new window? Usually the viewmodel shouldn’t care how this new window is opened or whether it is modal or not. In this case it would be easy to use a service:

    windowManager.ShowDetailsView();
    

    The WindowManager (which you use through IWindowManager interface) is responsible for displaying the details view. Maybe it is a modal view or maybe there is some kind of slide animation. The point is that the viewmodel that uses IWindowManager doesn’t care.

    In some cases you might need to receive notification if users clicks Ok or Cancel. You can still use the IWindowManager by having method like this:

    public void ShowEditView(Action userSavedChanged, Action userCancelled);
    

    Then just call it from the viewmodel

    windowManager.ShowEditView(this.SaveChanges, this.CancelChanges);
    
    // in your viewmodel you have the SaveChanges and CancelChanges methods
    private void SaveChanges()
    {
       // save the changes.
    }
    

    Hopefully this all makes some sense. After all it is friday 🙂

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

Sidebar

Related Questions

I am developing a rather large database schema using Entity Framework Code First. I
I am developping a (relatively small) website in ASP.Net 2.0. I am also using
I'm currently developping an application in java using Hibernate as a persistence manager and
I have been developing a book viewing website that takes rather large images (upwards
We are developing a large applications which are related to business. You can find
I am developing an application which at the moment queries a (rather large) database
I am developing a desktop application with a MainForm that's grown rather large. There
So I'm developing a rather large python project with a number of modules. The
I'm developing a rather large XML Schema to integrate multiple disparate systems. Each system
I'm new to developing web apps using ASP.NET MVC. In fact, I'm rather new

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.