public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { SearchFocus focus = (SearchFocus)value; if (focus != SearchFocus.Any) { return(Visibility.Visible); } return(Visibility.Collapsed); }
protected override void InitializeCommands() { base.InitializeCommands(); CreateArtist = new RelayCommand((o) => { Console.WriteLine("CreateArtistButton"); ApplicationViewModel.CreateView.Execute(new CreateArtistViewModel(ApplicationViewModel, DataProvider)); }); DelayedSearch = new RelayCommand((o) => (o as string) != null && (o as string).Length > 0, (o) => SearchByText(o as string)); NextResultPage = new RelayCommand(o => (songPage != null && songPage.TotalPages > Page) || (albumPage != null && albumPage.TotalPages > Page) || (artistPage != null && artistPage.TotalPages > Page), o => { Console.WriteLine("Next result page - current page: " + Page); if (SearchFocus == SearchFocus.Any) { return; } switch (SearchFocus) { case SearchFocus.Albums: if (Page < albumPage.TotalPages) { Page++; SearchByText(SearchText); } ; break; case SearchFocus.Artists: if (Page < artistPage.TotalPages) { Page++; SearchByText(SearchText); } ; break; case SearchFocus.Songs: if (Page < songPage.TotalPages) { Page++; SearchByText(SearchText); } ; break; } }); PreviousResultPage = new RelayCommand(o => Page > 1, o => { if (Page == 1) { return; } Page--; SearchByText(SearchText); }); SetSearchFocus = new RelayCommand(o => { SearchFocus sf = (SearchFocus)o; if (sf == SearchFocus) { SearchFocus = SearchFocus.Any; } else { SearchFocus = sf; } Page = 1; SearchByText(SearchText); }); }