Exemplo n.º 1
0
        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
            };
        }
Exemplo n.º 2
0
        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.
        }