Exemplo n.º 1
0
 // refresh the DataContext of the tree view if the underlying view model changes
 private void OnViewModelChange(object sender, ExplorerViewModelHelper.ExplorerViewModelChangedEventArgs args)
 {
     var viewModel = args.NewViewModel;
     Debug.Assert(viewModel != null, "Null ViewModel in ExplorerFrame.OnViewModelChange()");
     Debug.Assert(viewModel.RootNode != null, "Null ViewModel.RootNode in ExplorerFrame.OnViewModelChange()");
     ExplorerTreeView.DataContext = viewModel.RootNode;
 }
Exemplo n.º 2
0
        private void ReloadViewModel()
        {
            Debug.Assert(_context != null, "ExplorerFrame was disposed");
            // if _viewModelHelper doesn't exist then create and subscribe to ViewModelChanged event
            if (_viewModelHelper == null)
            {
                _viewModelHelper = GetNewExplorerViewModelHelper();
                _viewModelHelper.ExplorerViewModelChanged += OnViewModelChange;
            }

            // create a new ViewModel and assign it to the ViewModelHelper - this
            // will cause ViewModelChanged event to be fired and we will update
            // the DataContext in OnViewModelChange() below
            _viewModelHelper.CreateViewModel(_context);
        }