public MainContentViewModel() { eventAggregator = (IEventAggregator)ServiceLocator.Current.GetService(typeof(IEventAggregator)); DataInstance = new StartMenu { Name = "无限极树模板", ViewContent = new Views.TreeViewTemplate() }; eventAggregator.GetEvent <MenuTreeViewSelectedItemChanged>().Subscribe((s) => { DataInstance = s; }); }
public void AddView(StartMenu view) { var temp = new List <StartMenu>(); if (DataSource != null) { foreach (var entity in DataSource) { temp.Add(entity); } } temp.Add(view); DataSource = temp; }
public MenuViewModel() { AddView(new StartMenu(new Views.TreeViewTemplate()) { Name = "无限级树模板" }); AddView(new StartMenu(new Views.TreeViewWithContextMenu()) { Name = "模板选择器" }); AddView(new StartMenu(new Views.TreeViewWithCheckBox()) { Name = "复选框树模板" }); eventAggregator = (IEventAggregator)ServiceLocator.Current.GetService(typeof(IEventAggregator)); ShowContentCommand = new RelayCommand <StartMenu>((s) => { SelectedItem = s; eventAggregator.GetEvent <Events.MenuTreeViewSelectedItemChanged>().Publish(s); }); }