NodeDataEditorViewModel.cs 974 B

12345678910111213141516171819202122232425262728293031
  1. using Microsoft.Practices.Prism.Mvvm;
  2. using Microsoft.Practices.Prism.PubSubEvents;
  3. namespace Tree
  4. {
  5. public class NodeDataEditorViewModel: BindableBase
  6. {
  7. private IEventAggregator EventAggregator { get; set; }
  8. public TreeNodeViewModel TreeNodeViewModel { get; set; }
  9. public IEventNotifyView EventNotifyView { get; set; }
  10. public NodeDataEditorViewModel()
  11. {
  12. }
  13. public NodeDataEditorViewModel(IEventAggregator eventAggregator)
  14. {
  15. this.EventAggregator = eventAggregator;
  16. this.EventAggregator.GetEvent<SelectNodeChangeEvent>().Subscribe(this.OnSelectNodeChange);
  17. }
  18. private void OnSelectNodeChange(TreeNodeViewModel treeNodeViewModel)
  19. {
  20. this.TreeNodeViewModel = treeNodeViewModel;
  21. // 通知view层datacontext已经发生改变
  22. this.EventNotifyView.OnDataContextChange();
  23. }
  24. }
  25. }