Search and content discovery
Search and content discovery gives users one local search entry point for albums, artists, songs, videos, and playlists. It turns a query into typed suggestions or a grouped result view, then lets the user play media or open the matching content.
Search scope
The search service searches the current music library, video library, and playlist collection. It matches the name of each item without case sensitivity and keeps matches grouped by content type, so the result view can present each kind of content in its own context. It does not search remote services or metadata fields beyond the item name.
Search result model
Screenbox.Core.Models.SearchResult is the shared result model for a query. It carries the query text and separate lists for songs, videos, artists, albums, and playlists. The model also provides one empty-result check for the result page.
References: Screenbox.Core/…/SearchResult.cs• L6-50 Screenbox.Core/…/SearchService.cs• L32-71
Search suggestions
Suggestions provide a short, typed preview while the user enters a query. The service gathers candidates from all five content groups, limits the number taken from each group, ranks names by how closely the query occurs, and returns a small total set. A non-empty query with no match produces a typed empty suggestion so the search box can show a clear no-result state.
References: Screenbox.Core/…/ISearchService.cs• L6-15 Screenbox.Core/…/SearchService.cs• L73-129 Screenbox.Core/…/SearchSuggestion.cs• L5-32 Screenbox.Core/…/SearchSuggestionType.cs• L3-16 Screenbox/…/SearchSuggestionTemplateSelector.cs• L8-35
Search entry flow
The main page owns the search box and keeps its suggestions in sync with user input. A chosen suggestion acts as a direct action, while a submitted query without a chosen suggestion creates the grouped search result page.
This diagram shows how search input becomes either a direct content action or a full result view.
flowchart TD
A[User enters query] --> B[Search service finds local matches]
B --> C[Typed suggestions]
B --> D[Grouped search result]
C --> E{Suggestion selected?}
E -->|Song or video| F[Play media]
E -->|Album, artist, or playlist| G[Open content details]
E -->|No suggestion| D
D --> H[Open result sections]
Query submission
The main page trims the submitted text and ignores an empty query. A valid query is passed to the search service, and the resulting SearchResult becomes the navigation parameter for the grouped result page. After submission, the search box clears its suggestions and closes its pane when the layout allows it.
References: Screenbox.Core/…/MainPageViewModel.cs• L154-223 Screenbox/…/MainPage.xaml.cs• L306-342
Suggestion actions
Each suggestion carries both a display name and the matching view model. Selecting media starts playback. Selecting an album, artist, or playlist opens its detail page. This keeps suggestions useful as actions rather than treating them only as alternate query text.
References: Screenbox.Core/…/MainPageViewModel.cs• L205-223 Screenbox.Core/…/SearchSuggestion.cs• L11-32
Result navigation
The grouped result page is the central discovery view. It shows only the content groups that have matches, gives each group a suitable media view, and exposes a full category page when the group has more items than the compact view displays.
Grouped result view
SearchResultPageViewModel keeps the complete result model while exposing observable collections for the page. Artists and albums use grid sections. Songs use a list. Videos and playlists use media cards. The page supports direct opening of artists, albums, and playlists, plus playback for songs and videos.
References: Screenbox.Core/…/SearchResultPageViewModel.cs• L15-127 Screenbox/…/SearchResultPage.xaml• L91-229 Screenbox/…/SearchResultPage.xaml• L231-340
Category result views
The grouped page offers a separate view for artists, albums, songs, videos, or playlists when the compact section is not enough. These views reuse the loaded search result and present the full list for one category, so moving to a category view does not require a second search.
References: Screenbox.Core/…/SearchResultPageViewModel.cs• L129-157 Screenbox/…/ArtistSearchResultPage.xaml• L30-79 Screenbox/…/AlbumSearchResultPage.xaml• L33-88 Screenbox/…/SongSearchResultPage.xaml• L51-91 Screenbox/…/VideoSearchResultPage.xaml• L43-79 Screenbox/…/PlaylistSearchResultPage.xaml• L29-68
Content navigation
Search results connect discovery to the wider media library. Artists, albums, and playlists open their detail or collection views. Media items can play at once, and songs can also start playback with the complete song result list as the play queue.
References: Screenbox.Core/…/SearchResultPageViewModel.cs• L116-156 Screenbox/…/SearchResultPage.xaml• L27-87 Screenbox/…/PlaylistSearchResultPage.xaml• L39-64
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the five result categories aligned across
SearchService,SearchResult, the main grouped page, and the category pages. - Keep suggestion types aligned with their display template, ranking input, and action mapping in
MainPageViewModel. - Preserve the shared
SearchResultPageViewModelhand-off when changing category navigation. The category pages depend on the loaded query and result lists. - Keep media suggestion actions consistent with the distinction between immediate playback and detail-page navigation.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A result category is added in only one layer | The search service can find content that the model or UI cannot show | Update the service, result model, grouped view, category view, and suggestion mapping together |
| A suggestion has no matching data object | Choosing it does not navigate or play anything | Keep data-bearing suggestions separate from the explicit None suggestion |
| A category page receives no shared result view model | Its query and item list are unavailable | Navigate with the loaded SearchResultPageViewModel |
| A blank query reaches the search flow | The user can enter a result flow with no useful search term | Trim input and reject empty submissions before creating a result |
Key files
| File | Why to read it |
|---|---|
| Screenbox.Core/…/SearchService.cs | Defines local search scope, match behavior, and suggestion ranking. |
| Screenbox.Core/…/SearchResult.cs | Defines the cross-category result contract. |
| Screenbox.Core/…/SearchSuggestion.cs | Defines the data carried by search-box suggestions. |
| Screenbox.Core/…/MainPageViewModel.cs | Connects search-box input and selection to playback or navigation. |
| Screenbox.Core/…/SearchResultPageViewModel.cs | Coordinates grouped results, playback, and category navigation. |
Screenbox/Pages/Search/SearchResultPage.xaml | Shows how the grouped result experience is organized. |
Screenbox/Pages/Search/SongSearchResultPage.xaml | Shows the full-category media result pattern. |
Screenbox/Pages/Search/ArtistSearchResultPage.xaml | Shows the full-category entity result pattern. |
Screenbox/Pages/Search/AlbumSearchResultPage.xaml | Shows album discovery and related artist navigation. |
Screenbox/Pages/Search/VideoSearchResultPage.xaml | Shows video playback from search results. |
Screenbox/Pages/Search/PlaylistSearchResultPage.xaml | Shows playlist navigation and actions from search results. |