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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:19:44+00:00 2026-05-24T08:19:44+00:00

How may I ensure that my childwindow is unloaded when it’s closed? I am

  • 0

How may I ensure that my childwindow is unloaded when it’s closed?

I am opening the childwindow from my viewmodel, but after it’s been closed it still fires of events like selectionchanged on comboboxes.

The childwindow is using the same viewmodel as it’s been called from, so I guess that explains why the events are being fired. The itemssources are still valid.

But when it’s closed, I would like to “dispose” the childwindow for good.

I’ve tried to add a Closed handler like this (Default view code behind):

    private void OnLaunchEditItem(ItemMessage msg)
    {
        var editWnd = new EditItemWindow();
        editWnd.Closed += new EventHandler(editWnd_Closed);
        editWnd.Show();
    }

    void editWnd_Closed(object sender, EventArgs e)
    {
        sender = null;
    }

No sucesss..

So what I’m doing now is to remove the itemssource from the childwindow controls, which seems to me… not the ideal solution to the problem. It must be possible to dispose it all from memory on closing? (Childwindow “view” code-behind)

    private void OKButton_Click(object sender, RoutedEventArgs e)
    {
        this.DialogResult = true;
        combobox1.ItemsSource = null;
        combobox2.ItemsSource = null;
    }

    private void CancelButton_Click(object sender, RoutedEventArgs e)
    {
        this.DialogResult = false;
        combobox1.ItemsSource = null;
        combobox2.ItemsSource = null;
    }
  • 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-24T08:19:45+00:00Added an answer on May 24, 2026 at 8:19 am

    The messaging has a known problem that it introduces a hard link between the messenger and the recipient of a message. So if you use messaging you havee to ensure that the Messenger.Unregister method is called. In other words, when you call Register to handle a messsage make sure you call Unregister as well!

    So in your view you have to register for the Unloaded event; there you then call Messenger.Unregiser(this); where this is your view.

    In ViewModels you have to make sure that the Cleanup method is called to deregister the ViewModel as a message recipient.

    Also see:

    MVVM Light Listener not releasing / deterministic finalization for registered object? and MVVM Light Messenger executing multiple times.

    Laurent is aware of this Problem but – as of now – has no solution.

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

Sidebar

Related Questions

VB.NET: What is the best way to ensure that a particular object may be
How to ensure that the exception thrown by @Asynchronous method from EJB 3.1 methods
I am wondering how to ensure that an employee cannot access information from another
This may be a simple question, but I have been Googling for over an
May I know how could I pass the value of driver from code behind
May be obvious but I tried searching and can't figure it out. I am
May I know if there is any way to remove non-alphabetical symbols from a
May be I am getting old, but I can't find it...
I'm planning on running a ruby process that may take a month to finish.
I am using transactionscope to ensure that data is being read to the database

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.