public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue) { DemoItems = new ObservableCollection <DemoItem>(new[] { new DemoItem( "Home", typeof(Home), new[] { new DocumentationLink( DocumentationLinkType.Wiki, $"{ConfigurationManager.AppSettings["GitHub"]}/wiki", "WIKI"), DocumentationLink.DemoPageLink <Home>() } ) }); foreach (var item in GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name)) { DemoItems.Add(item); } _demoItemsView = CollectionViewSource.GetDefaultView(DemoItems); _demoItemsView.Filter = DemoItemsFilter; HomeCommand = new AnotherCommandImplementation( _ => { SearchKeyword = string.Empty; SelectedIndex = 0; }); MovePrevCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex--; }, _ => SelectedIndex > 0); MoveNextCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex++; }, _ => SelectedIndex < DemoItems.Count - 1); }
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue) { DemoItems = new ObservableCollection <DemoItem> { new DemoItem( "Home", typeof(Home), new[] { new DocumentationLink( DocumentationLinkType.Wiki, $"{ConfigurationManager.AppSettings["GitHub"]}/wiki", "WIKI"), DocumentationLink.DemoPageLink <Home>() }, selectedIcon: PackIconKind.Home, unselectedIcon: PackIconKind.HomeOutline) }; foreach (var item in GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name)) { DemoItems.Add(item); } MainDemoItems = new ObservableCollection <DemoItem> { DemoItems.First(x => x.Name == "Home"), DemoItems.First(x => x.Name == "Buttons"), DemoItems.First(x => x.Name == "Toggles"), DemoItems.First(x => x.Name == "Fields"), DemoItems.First(x => x.Name == "Pickers") }; _demoItemsView = CollectionViewSource.GetDefaultView(DemoItems); _demoItemsView.Filter = DemoItemsFilter; HomeCommand = new AnotherCommandImplementation( _ => { SearchKeyword = string.Empty; SelectedIndex = 0; }); MovePrevCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex--; }, _ => SelectedIndex > 0); MoveNextCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex++; }, _ => SelectedIndex < DemoItems.Count - 1); DismissAllNotificationsCommand = new AnotherCommandImplementation( _ => DemoItems[0].DismissAllNotifications(), _ => DemoItems[0].Notifications != null); AddNewNotificationCommand = new AnotherCommandImplementation( _ => DemoItems[0].AddNewNotification()); AddNewNotificationCommand.Execute(new object()); }