public StateChangeGraphViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, wf.StateChangeDefinition change) : base(appCtx, dataCtx, parent) { StateChange = change; StateChange.PropertyChanged += (s, e) => { switch (e.PropertyName) { case "Name": OnPropertyChanged("Name"); break; } }; }
private StateChangeGraphViewModel ToStateChangeViewModel(wf.StateChangeDefinition change) { if (!_stateChangeViewModels.ContainsKey(change)) { var vm = _stateChangeViewModels[change] = ViewModelFactory.CreateViewModel <StateChangeGraphViewModel.Factory>().Invoke(DataContext, this, change); vm.IsSelectedChanged += (s, e) => { var sender = (StateChangeGraphViewModel)s; if (sender.IsSelected) { _stateChangeViewModels.Values.Except(new[] { sender }).ForEach(i => i.IsSelected = false); SelectedStateChange = sender; } else if (SelectedStateChange == sender) { SelectedStateChange = null; } }; } return(_stateChangeViewModels[change]); }