Class SearchViewModel
Backing controller for a search experience, intended for use with SearchView. SearchView supports searching, with search-as-you-type for multiple search providers via ISearchSource.
Implements
Namespace: Esri.ArcGISRuntime.Toolkit.UI.Controls
Assembly: Esri.ArcGISRuntime.Toolkit.WinUI.dll
Syntax
public class SearchViewModel : INotifyPropertyChanged
Properties
| Improve this Doc View SourceActivePlaceholder
Gets the correct placeholder to display in the UI.
Declaration
public string ActivePlaceholder { get; }
Property Value
Type | Description |
---|---|
String |
ActiveSource
Gets or sets the active search source, if one is selected. If there is no selection, all sources will be used for the search.
Declaration
public ISearchSource ActiveSource { get; set; }
Property Value
Type | Description |
---|---|
ISearchSource |
CurrentQuery
Gets or sets the current query.
Declaration
public string CurrentQuery { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
Call UpdateSuggestions() to refresh suggestions after updating the query.
DefaultPlaceholder
Gets or sets the default placeholder to use when there is no ActiveSource or the ActiveSource does not have a placeholder defined. Consumers should always display the ActivePlaceholder in the UI, rather than accessing this property directly.
Declaration
public string DefaultPlaceholder { get; set; }
Property Value
Type | Description |
---|---|
String |
IgnoreAreaChangesFlag
Gets or sets a value indicating whether changes to the query area should be ignored. This is used to prevent IsEligibleForRequery becoming true because the view zoomed to a result.
Declaration
public bool IgnoreAreaChangesFlag { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Set this value to true when the GeoView is being navigated to show results, and set to false when the navigation completes.
IsEligibleForRequery
Gets a value indicating whether spatial parameters have changed enough to justify displaying a 'Repeat Search Here' button.
Declaration
public bool IsEligibleForRequery { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
'Repeat Search Here' is a common pattern in applications that return multiple search results.
IsSearchInProgress
Gets a value indicating whether a search operation is in progress.
Declaration
public bool IsSearchInProgress { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsSuggestInProgress
Gets a value indicating whether a suggestion request is in progress.
Declaration
public bool IsSuggestInProgress { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsWaiting
Gets a value indicating whether a waiting operation (search, suggestion) is in progress.
Declaration
public bool IsWaiting { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This can be used to implement activity indicator or progress bar display.
QueryArea
Gets or sets the query area to use when searching and getting suggestions. When used in conjunction with a GeoView, this property should be set every time navigation completes, to enable automatic update of the IsEligibleForRequery property.
Declaration
public Geometry.Geometry? QueryArea { get; set; }
Property Value
Type | Description |
---|---|
Nullable<Geometry.Geometry> |
QueryCenter
Gets or sets the center point around which results should be returned.
Declaration
public MapPoint? QueryCenter { get; set; }
Property Value
Type | Description |
---|---|
Nullable<MapPoint> |
Results
Gets the list of search results for the most-recently completed query.
Clearing a search via ClearSearch() will set this collection to null
.
Declaration
public IList<SearchResult> Results { get; }
Property Value
Type | Description |
---|---|
IList<SearchResult> |
SearchMode
Gets or sets the search mode, which defaults to Automatic. This mode controls how many results are displayed when a search is performed.
Declaration
public SearchResultMode SearchMode { get; set; }
Property Value
Type | Description |
---|---|
SearchResultMode |
SelectedResult
Gets or sets the selected search result.
Declaration
public SearchResult SelectedResult { get; set; }
Property Value
Type | Description |
---|---|
SearchResult |
Sources
Gets or sets the list of available search sources, which can be updated dynamically.
Declaration
public IList<ISearchSource> Sources { get; set; }
Property Value
Type | Description |
---|---|
IList<ISearchSource> |
Remarks
See ConfigureDefaultWorldGeocoder(CancellationToken) for a convenient method to populate this collection automatically.
Suggestions
Gets the list of search suggestions. This value is set after calls to UpdateSuggestions().
Declaration
public IList<SearchSuggestion> Suggestions { get; }
Property Value
Type | Description |
---|---|
IList<SearchSuggestion> |
Methods
| Improve this Doc View SourceAcceptSuggestion(SearchSuggestion)
Initiates a search using a suggestion as the query.
Declaration
public async Task AcceptSuggestion(SearchSuggestion suggestion)
Parameters
Type | Name | Description |
---|---|---|
SearchSuggestion | suggestion | A suggestion from Suggestions to be used as basis for the search. |
Returns
Type | Description |
---|---|
Task |
Remarks
This will update CurrentQuery to match the selected suggestion.
CancelSearch()
Cancels any active search task.
Declaration
public void CancelSearch()
CancelSuggestion()
Cancels any active suggest task.
Declaration
public void CancelSuggestion()
ClearSearch()
Cancels any active search/suggest tasks, then clears all results and the current query.
Declaration
public void ClearSearch()
CommitSearch()
Submits the current query as a fresh search.
Declaration
public async Task CommitSearch()
Returns
Type | Description |
---|---|
Task |
Remarks
The search will return results from the ActiveSource or all Sources if ActiveSource is null
.
Search in progress can be cancelled by calling CancelSearch().
ConfigureDefaultWorldGeocoder(CancellationToken)
Configures the viewmodel with a search source optimized for use with the Esri World Geocoder service.
Declaration
public async Task ConfigureDefaultWorldGeocoder(CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | Token used for cancellation. |
Returns
Type | Description |
---|---|
Task |
RepeatSearchHere()
Repeats the current search, with results confined to the area defined by QueryArea.
Declaration
public async Task RepeatSearchHere()
Returns
Type | Description |
---|---|
Task |
Remarks
This is used to allow users to narrow down search results using a geographic constraint. This is especially useful when a search results in multiple results.
UpdateSuggestions()
Updates Suggestions for the current query.
Declaration
public async Task UpdateSuggestions()
Returns
Type | Description |
---|---|
Task |
Events
| Improve this Doc View SourcePropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |