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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:45:56+00:00 2026-06-14T08:45:56+00:00

I am having a strange behavior that I believe is related to the Binding.

  • 0

I am having a strange behavior that I believe is related to the Binding. Basically, I suspect that the binding of my controls on my ViewModel creates a strong reference from the PropertyChanged event to the control. So the ViewModel always keeps a reference to the controls. Therefore, even though I am done with the controls, they are always kept in memory. This will remain until I destroy my ViewModel, but in my case, I have one ViewModel for everything. Is there a way I can unhook the events created by the bindings?

Here is a more detailed explanation of my issue, and the one that lead me to the above belief:

I have a ViewModel:

public ViewModel()
{
    InitializeCommands();
}

public ICommand OpenPropertiesCommand { get; set; }

private void InitializeCommands()
{
    OpenPropertiesCommand = new DelegateCommand((o) =>
    {
        OpenProperties(o as ContentControl);
    });
}

private void OpenProperties(ContentControl propertiesWindowOwner)
{
    JobProperties jp = new JobProperties(this);
    jp.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterOwner;
    jp.Owner = propertiesWindowOwner;
    jp.ShowDialog();
}

private Job selectedJob;
public Job SelectedJob
{
    get
    {
        return selectedJob;
    }
    set
    {
        selectedJob = value;
        RaisePropertyChanged("SelectedJob");
    }
}

This ViewModel is used by my Main control. On this control, I have a GridView where each Row is a “Job”. You can edit Job’s properties, which will in turn open a RadWindow Control that lets you edit each job’s properties.

My PropertyEdit Control is a RadWindow that uses the same ViewModel as it’s DataContext. All of it’s components bind on SelectedJob.something where something is a property of Job.

If I open Job #1 properties. A PropertyEdit control is created and binding is established. My properties SelectedJob.something are getting accessed once for each binding as should be. If I close the PropertyEdit control and open Job #1 properties again. One more PropertyEdit control is created and binding is established. Now if I close this one, and select another Job, a PropertyChanged event is called on selectedJob and my bindings are called twice for each binding. In effect, the first PropertyEdit control binding are activated, and the second PropertyEdit bindings are also activated. Now if I opened Job #1 properties 100 times, when I select Job #2, bindings will be queried 100 times for each one of them. Therefore, I suspect a memory leak, where the bindings are keeping my PropertyEdit control in memory, because they hold a reference to all of them. Until I destroy my ViewModel, those references will be kept, but in my case, it is my Main app’s ViewModel, and will never be destroyed. How can I prevent this from happening? Is there a way I can unregister the binding’s events manually?

Thank You.

  • 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-14T08:45:57+00:00Added an answer on June 14, 2026 at 8:45 am

    I have solved this issue. The problem was not with the binding, but it seems that the Owner property of the Window somehow stops the window from being garbage collected.

    By commenting out this line:

    jp.Owner = propertiesWindowOwner;
    

    I solved the issue. I am not sure why this is. I suspect that setting the owner of the window has the side effect of setting the window as the child of the propertiesWindowOwner. Therefore, until I destroy the propertiesWindowOwner, it would keep a reference to my window, even after closing it.

    I am a bit confused as to why this happens, and what I am required to do not to leak memory when doing this. If anyone knows, please comment on this.

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

Sidebar

Related Questions

i'm having strange behavior from the for loop in python. The problem is not
We have an iOS application for the iPad that is having strange behavior. We
I'm having some strange behavior where my MPMoviePlayerViewController isn't auto -rotating when the orientation
I'm having a very strange behavior with a C# class 'Digital', mapped to an
I'm having a strange problem, that I've been trying to solve for too long.
I am having strange behaviour when using jquery.on(). Basically, just trying to create a
I'm having a very strange problem where my execution jumps from semi-predictable locations to
I am having this strange behavior when performing a method which the if statement
I am currently having a strange issue with an application migrated from rails 2.3.8
Having a very strange behavior problem with a UITextView. In IB Storyboard I dropped

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.