c# - Caliburn.Micro - OnDeactivate Not triggering -
i'm having unusual issue, , im pretty much @ wits end trying work out.
i have conductor activates , deactivates viewmodels used editing data, these view models implements screen , utilize ondeactivate ensure changes saved before closing.
however reason, ondeactivate in 1 of viewmodels never called, tho can see beingness passed deactivateitem of conductor.
to have next in conductor:
private void switchscreen(screen viewmodel) { deactivateitem(activeitem, true); activateitem(viewmodel); notifyofpropertychange(() => projectactionregion); } public override void deactivateitem(iscreen item, bool close) { base.deactivateitem(item, close); notifyofpropertychange(() => projectactionregion); }
this ensures when tryclose called part correctly updated. switchscreen called each time selection made on datagrid, loading viewmodel. can see deactivate item called when alter selection, , can see passing right viewmodel method.
however ondeactivate still never called, , have no thought why :/
protected override void ondeactivate(bool close) { system.windows.forms.messagebox.show("save me!"); }
edited remove wrong code (the base. mistake, actual code)
edit:
i've realized difference between working versions , broken version is. have view/viewmodel works conductor, works fine. within viewmodel load sec view/viewmodel works conductor, 1 fails work, wonder if has with beingness within conductor (but not handled conductor, loaded viewmodel)
for screen life-cycle function correctly, of view models in view hierarchy must conducted. should create kid conductor active screen of parent conductor.
you can either making active item of parent conductor, or using conductwith
method on kid conductor, passing in reference parent conductor.
c# wpf mvvm caliburn.micro
No comments:
Post a Comment