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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:55:34+00:00 2026-05-22T01:55:34+00:00

I have a view named Work.xaml. This Work.xaml contains multiple WorkSkeleton.xaml. The Work.xaml’s ViewModel

  • 0

I have a view named Work.xaml. This Work.xaml contains multiple WorkSkeleton.xaml. The Work.xaml’s ViewModel is WorkViewModel.

The Work.xaml is contained in MainPage.xaml which has button to load Work.xaml. I hope I am clear till now. The button’s event handler is simple :-

 private void hypMyWork_Click(object sender, RoutedEventArgs e)
        {
            ShowGridContent(new Work());
        }

 private void ShowGridContent(UserControl control)
        {
            gridContent.Children.Clear();
            gridContent.Children.Add(control);
        }

In my Work.xaml.cs’s Constructor I have registered for Messages of type ObservableCollection:

    Messenger.Default.Register<ObservableCollection<WorkEducation>>(this, "BindWorkEducationList", collection =>
    {
        foreach (var item in collection)
        {
            if (item.IsEducationInfo == false)
            {
                WorkEducationSkeleton skeleton = new WorkEducationSkeleton();
                skeleton.WorkEducation = item;
                stkPanel.Children.Insert(0,skeleton);

            }
        }
    });

The ViewModel is sending this message when the ObservableCollection is loaded like this :-

 Messenger.Default.Send<ObservableCollection<WorkEducation>>(WorkEducation,
                    "BindWorkEducationList");

Everything works fine the 1st time. But as soon as I click the Work button in MainPage.xaml to load the Work page 2nd time, the messages are received in my Work.xaml 2 times which adds the same items to stackpanel again and again. This happens N times. If I clicked the button Nth time the message will be received N times in Work.xaml.cs. But how is this possible?

I have clearly specified the recepient in Work.xaml.cs to be this as the 1st parameter which means the message is to be received for this particular instance. On click of Work button the instance is completely new. Then why is it firing N times?

  • 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-22T01:55:35+00:00Added an answer on May 22, 2026 at 1:55 am

    Are you sure it’s firing N times for the same instance? You probably have N instances lying around (N-1 waiting to be garbage collected) and that’s why you’re seeing it N times.

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

Sidebar

Related Questions

Given that I have the following widget (and a view attached to it): public
Lets say I have a set of model classes like this: public class Person
Below is the XAML i currently have. I want to emulate a tree by
This is my first post to stackoverflow so if I've done anything wrong I
I'm currently binding a list view to a list of objects and everytrhing is
I have a WPF application with a NotifyIcon defined in a ResourceDictionary that is
I'm learning how to make a Visual Studio style properties grid. I have a
My goal is to add different Controls/UserControls in a WPF ListView. The Controls can
I'm building an application using WPF and MVVM. I've come across a situation where

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.