コード例 #1
0
        private void DestroyViewModel()
        {
            if (this.viewModel == null)
            {
                return;
            }

            this.DataContext = null;
            this.viewModel.Dispose();
            this.viewModel = null;
        }
コード例 #2
0
        private void RefreshViewModel()
        {
            if (this.WindowState != GameWindowState.Opened &&
                this.WindowState != GameWindowState.Opening ||
                this.itemsContainer == null)
            {
                return;
            }

            if (this.viewModel != null)
            {
                if (this.viewModel.ViewModel.Container == this.itemsContainer)
                {
                    // already displaying window for this container
                    return;
                }

                this.DestroyViewModel();
            }

            this.viewModel   = new ViewModelWindowContainerExchange(this.itemsContainer, this.Close);
            this.DataContext = this.viewModel;
        }