public MainViewModel() { // Initialize MEF var catalog = new DirectoryCatalog("Tricks"); _container = new CompositionContainer(catalog); _container.ComposeParts(this); var tricks = new List<TrickViewModel>(); foreach (var trick in _tricks) { var Trick = new TrickViewModel { Name = trick.Metadata.Name, Description = trick.Metadata.Description }; tricks.Add(Trick); } Tabs = new ObservableCollection<TabItem> { new TabItem { Header = "All Tricks", IsSelected = true, Content = new TricksTab(tricks) } }; Messenger.Default.Register<LoadMessage>(this, (m) => OnLoadTab(m.Trick)); }
public MainViewModel() { // Initialize MEF var catalog = new DirectoryCatalog("Tricks"); _container = new CompositionContainer(catalog); _container.ComposeParts(this); var tricks = new List <TrickViewModel>(); foreach (var trick in _tricks) { var Trick = new TrickViewModel { Name = trick.Metadata.Name, Description = trick.Metadata.Description }; tricks.Add(Trick); } Tabs = new ObservableCollection <TabItem> { new TabItem { Header = "All Tricks", IsSelected = true, Content = new TricksTab(tricks) } }; Messenger.Default.Register <LoadMessage>(this, (m) => OnLoadTab(m.Trick)); }
public void OnLoadTab(TrickViewModel selectedTrick) { var trick = _tricks .Where(t => t.Metadata.Name == selectedTrick.Name) .FirstOrDefault(); var tab = new TabItem(); tab.Header = selectedTrick.Name; tab.IsSelected = true; tab.Content = trick.CreateExport().Value; AddTab(tab); }
public void OnLoadTab(TrickViewModel selectedTrick) { var trick = _tricks .Where(t => t.Metadata.Name == selectedTrick.Name) .FirstOrDefault(); var tab = new TabItem(); tab.Header = selectedTrick.Name; tab.IsSelected = true; tab.Content = trick.CreateExport().Value; AddTab(tab); }