c# - Catch "switching workspaces" event in MVVM -


i have application build mvvm pattern josh smith (http://msdn.microsoft.com/en-us/magazine/dd419663.aspx).

when have several workspaces opened in app, want catch event of switching workspaces/tabs can save content of current workspace first. have looked throught workspaceviewmodel , viewmodelbase, don't know how add eventhandler.

i have found solution in post, had tweak little bit : what proper way handle multiple datagrids in tab control cells leave edit mode when tabs changed?

basically have added eventhandler on previewmousedown of tabcontrol generating different workspaces.

private void tabcontrol_previewmousedown(object sender, mousebuttoneventargs e) {         mainwindow_vm dc = (mainwindow_vm)this.datacontext;          if (isundertabheader(e.originalsource dependencyobject))             //do need done before switching workspace             // in case, switch focus dummy control objectcontext save everything, focused textbox      }  private bool isundertabheader(dependencyobject control)      {         if (control tabitem)         {             return true;         }         dependencyobject parent = visualtreehelper.getparent(control);          if (parent == null)                      return false;           return isundertabheader(parent);      } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -