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

  • Home
  • SEARCH
  • 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 842961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:02:58+00:00 2026-05-15T06:02:58+00:00

I have a quite simple scenario that I cannot get to work correctly. I

  • 0

I have a quite simple scenario that I cannot get to work correctly. I have 2 views, CarView and CarWindowView (childwindow) with corresponding ViewModels. In my CarView I have an EditButton that that opens CarWindowView (childwindow) where I can edit the Car object fields.

My problem is that the DisplayModule method in my CarWindowView ViewModel is getting called too many times…When I push the edit button first time its getting called once, the second time its getting called twince, the third time its getting called 3 times and so fort… !

CarView ViewModel constructor:

Public Sub New(ByVal eventAggregator As IEventAggregator, ByVal con As IUnityContainer, ByVal mgr As ICarManager, ByVal CarService As ICarService)

    _Container = con
    _CarManager = mgr
    _EventAggregator = eventAggregator

    'Create the DelegateCommands
    NewBtnClick = New DelegateCommand(Of Object)(AddressOf HandleNewCarBtnClick)
    EditBtnClick = New DelegateCommand(Of Object)(AddressOf HandleEditCarBtnClick)
End Sub

CarView ViewModel HandleEditCarBtnClick method:

Private Sub HandleEditCarBtnClick()

    Dim view = New CarWindowView
    Dim viewModel = _Container.Resolve(Of CarWindowViewModel)()
    viewModel.CurrentDomainContext = DomainContext

    viewModel.CurrentItem = CurrentItem
    viewModel.IsEnabled = False

    view.ApplyModel(viewModel)
    view.Show()

    _EventAggregator.GetEvent(Of CarCollectionEvent)().Publish(EditObject)
End Sub

CarWindowView ViewModel constructor:

Public Sub New(ByVal eventAggregator As IEventAggregator, ByVal con As IUnityContainer, ByVal mgr As ICarManager, ByVal CarService As ICarService)

    _Container = con
    _CarManager = mgr
    _EventAggregator = eventAggregator

    _EventAggregator.GetEvent(Of CarCollectionEvent).Subscribe(AddressOf DisplayModule)

End Sub

CarWindowView ViewModel DisplayModule method (this is the method getting called too many times):

Public Sub DisplayModule(ByVal param As String)
If param = EditObject Then
  IsInEditMode = True
  ' Logic removed for display reasons here. This logic breaks because it's called too    many times.
  End If
End Sub

So, I cannot understand how I can only have the EventAggregator to store just the one single click, and not all my click on the Edit button. Sorry if this is not to well explained! Help appreciated!!

  • 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-15T06:02:59+00:00Added an answer on May 15, 2026 at 6:02 am

    It sounds like you have a memory leak of CarWindowViewModel. In other words, you have multiple instances of that class that have not been garbage collected. In the debugger, look at GetHashCode. I’m willing to bet that they are different.

    Assuming you are using the EventAggregator from Prism, it is supposed to keep a weak reference to your object, so that is not your problem.

    Most likely, you need to ensure that when that ViewModel is done, it unsubscribes from the event. Also, see if you can figure out what in the referance chain is keeping them alive.

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

Sidebar

Related Questions

I am trying to accomplish something that seemed quite simple... I have 3 div
I have (after quite a bit of work) a web test that will upload
I have the following JUnit test. The method that I'm testing is quite simple,
I have quite a few RewriteRules in my .htaccess that looks like this RewriteRule
I have quite a few cells that link to other worksheets/books, etc with standard
I'm trying to write a Cucumber scenario that requires me to have a logged
I'm using Thread::Pool::Simple for multi-threading. I have a couple of questions which are quite
I have a simple php file with a GET from a form to throw
The scenario is quite straight forward: I have content in table A and tags
I have quite a large list of words in a txt file and I'm

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.