Can't override DeactivateView

Sep 23, 2013 at 1:47 PM

Here's an interesting one. In three of my viewmodels I override the DeactivateView method in BaseViewModel. In one case, the code in the override gets executed, but in the other two the debugger goes into the empty virtual method in BaseViewModel rather than the override. Anybody got any ideas what might be going on?

I override ActivateView in nearly all my viewmodels, too, and that code always gets executed as I'd expect.

Sep 24, 2013 at 10:56 AM
OK, I've worked out what was going on, in case anybody is reading this.

In my navigation viewmodel, I call the Deactivate method on the viewmodel of the outgoing view before replacing it with the new view. The problem was that I was passing the view tag into the Router.ResolveViewModel method. This works in most cases (in my app at least), where the view's tag and the viewmodel's tag are the same. But in this particular case, there happened to be a viewmodel with the same tag as the view, but it wasn't the one the view was bound to. Now I've found that, and am getting the correct viewmodel, the override is being executed as you'd expect and everything is dinky-do.