Class SearchPageViewModel

This example shows how to trigger a search from code and display it in a listbox. While this isn't a very useful Controller pattern as the PdfView already offers a better inline search, it still shows of some of the concepts of how to be able to search programmatically.

Inheritance
System.Object
SearchPageViewModel
Implements
System.ComponentModel.INotifyPropertyChanged
Namespace: Catalog.ViewModels
Assembly: Catalog.dll
Syntax
public class SearchPageViewModel : Observable, INotifyPropertyChanged

Properties

DoSearchCommand

Asks the user for a search term and executes the search.

Declaration
public ICommand DoSearchCommand { get; }
Property Value
Type Description
System.Windows.Input.ICommand

SearchResults

A ObservableCollection that our list view can bind on.

Declaration
public ObservableCollection<SearchPageViewModel.SearchResultFormatter> SearchResults { get; }
Property Value
Type Description
System.Collections.ObjectModel.ObservableCollection<SearchPageViewModel.SearchResultFormatter>

Methods

Initialize(PdfView)

Initializes the view model with the Pdf view. This is necessary as we have to trigger the search from the view.

Declaration
public void Initialize(PdfView pdfView)
Parameters
Type Name Description
PdfView pdfView

The Pdf view of the page

Implements

System.ComponentModel.INotifyPropertyChanged