private void AddTab() { var newTab = new MainTabViewModel(this, string.Format("Tab {0}", this._tabIndex++)); this.SelectedTab = newTab; this.Tabs.Add(newTab); // The translation from view model to view is usually done by our ViewFactory. newTab.View = new MainTabView { ViewModel = newTab }; }
public void RemoveTab(MainTabViewModel mainTabViewModel) { this.Tabs.Remove(mainTabViewModel); if (mainTabViewModel == this.SelectedTab) { this.SelectedTab = null; } // The separation of view and view model is usually done by our ViewFactory. var view = mainTabViewModel.View; mainTabViewModel.View = null; view.ViewModel = null; // HINT: Commenting the previous block out and leaving view and view model bound, no warning occurs. // This seems clear because the animation will not be interupted. }