Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

Commented Unassigned: Caliburn.Micro subscribes multiple times to PropertyChanged [326]

$
0
0
I have the problem that CM seems to subscribe twice to PropertyChanged. Or, depending on the POV / expected behavior: It doesn't *unsubscribe* when the item is deactivated.

The scenario is the following:

I have a view model (`OuterViewModel` in the sample) that has a property (`CurrentInnerViewModel`) of another view model (`InnerViewModel`).

Outer has a button. A click on the button cycles through all inner view models it knows, one at a time. When there are no more, it activates the next screen (`NextViewModel`) (see `OuterViewModel.ShowNext`).

Next has a button that simply activates the previous screen.

Now, clicking in fast succession on the "Show next" and "Show previous" buttons with an attached debugger shows that multiple views get created for a single raised PropertyChanged event (see Output pane).



Comments: > The view is created because you forced it by creating This is incorrect. The problem is that the `InnerView` is created multiple times. This has nothing to do with `NextViewModel`. Furthermore, even when I only ever create one instance of `NextViewModel` in the constructor of `OuterViewModel` and reuse that, the problem still happens. Thanks for re-opening the issue.

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>