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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:18:12+00:00 2026-06-11T09:18:12+00:00

In my wpf application I have several user controls, one of them is a

  • 0

In my wpf application I have several user controls, one of them is a TreeView for selection of a particular data type. When selectedItem changes, I publish a selectionChanged event (using Prism’s EventAggregator) and a subscriber will get this event. So far, so good.

Now, I start to use the same user control in a new view, actuall in a new window. When selectionChanged event is fired from the new window, both subscriptions are triggered. I would like to specify the sender of the event, so that the subscriber can check who the event is intended for. There are many ways I can do this, but I none that I like so far.

So the question goes out to you guys, how can I achieve this?

  • 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-11T09:18:14+00:00Added an answer on June 11, 2026 at 9:18 am

    The simplest way to achieve this would be to add the sender to your published event args.

    public class SelectionChangedEventArgs
    {
        public object Sender { get; set; }
    
        // Other properties (e.g. SelectedItem, etc.)
    }
    

    Then as you said, you could easily check the sender to know whether you should handle the event. Prism already provides such a feature, with the following overload of Subscribe:

    public virtual SubscriptionToken Subscribe(Action<TPayload> action,
                                               ThreadOption threadOption,
                                               bool keepSubscriberReferenceAlive,
                                               Predicate<TPayload> filter);
    

    So you can actually provide a filter that checks the Sender property when subscribing, so your handler will only be called when this condition is met.

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

Sidebar

Related Questions

I have WPF Application where I have One main form and other user controls
So I have several comboboxes in my WPF application that don't change the selection
I have a WPF application with several windows. I would like to define GLOBAL
In a WPF/MVVM application I have a custom control on a particular view. This
I have a WPF application which has a main window composed from several custom
I have a WPF application containing several ComboBoxes . The ItemsSource of some of
I have a .NET 4.0 WPF application where the user can change the language
I have a WPF application in PRISM architecture. I have a user-control (view) that
I have a WPF Application project with several project references within a single solution
Assume I have several Views in my WPF application that all show a report,

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.