Show / Hide Table of Contents

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.

Inheritance
Object
SearchViewModel
Implements
INotifyPropertyChanged
Namespace: Esri.ArcGISRuntime.Toolkit.Maui
Assembly: Esri.ArcGISRuntime.Toolkit.Maui.dll
Syntax
public class SearchViewModel : INotifyPropertyChanged

Properties

| Improve this Doc View Source

ActivePlaceholder

Gets the correct placeholder to display in the UI.

Declaration
public string ActivePlaceholder { get; }
Property Value
Type Description
String
| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

IsSearchInProgress

Gets a value indicating whether a search operation is in progress.

Declaration
public bool IsSearchInProgress { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

IsSuggestInProgress

Gets a value indicating whether a suggestion request is in progress.

Declaration
public bool IsSuggestInProgress { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

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.

| Improve this Doc View Source

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>
| Improve this Doc View Source

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>
| Improve this Doc View Source

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>
| Improve this Doc View Source

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
| Improve this Doc View Source

SelectedResult

Gets or sets the selected search result.

Declaration
public SearchResult SelectedResult { get; set; }
Property Value
Type Description
SearchResult
| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

AcceptSuggestion(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.

| Improve this Doc View Source

CancelSearch()

Cancels any active search task.

Declaration
public void CancelSearch()
| Improve this Doc View Source

CancelSuggestion()

Cancels any active suggest task.

Declaration
public void CancelSuggestion()
| Improve this Doc View Source

ClearSearch()

Cancels any active search/suggest tasks, then clears all results and the current query.

Declaration
public void ClearSearch()
| Improve this Doc View Source

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().

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

UpdateSuggestions()

Updates Suggestions for the current query.

Declaration
public async Task UpdateSuggestions()
Returns
Type Description
Task

Events

| Improve this Doc View Source

PropertyChanged

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
PropertyChangedEventHandler

Implements

INotifyPropertyChanged
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX