Udostępnij za pośrednictwem


SearchSuggestionCollection.AppendResultSuggestion Method

Definition

Appends a suggested search result to the list of suggestions to display in the search pane.

public:
 virtual void AppendResultSuggestion(Platform::String ^ text, Platform::String ^ detailText, Platform::String ^ tag, IRandomAccessStreamReference ^ image, Platform::String ^ imageAlternateText) = AppendResultSuggestion;
void AppendResultSuggestion(winrt::hstring const& text, winrt::hstring const& detailText, winrt::hstring const& tag, IRandomAccessStreamReference const& image, winrt::hstring const& imageAlternateText);
public void AppendResultSuggestion(string text, string detailText, string tag, IRandomAccessStreamReference image, string imageAlternateText);
function appendResultSuggestion(text, detailText, tag, image, imageAlternateText)
Public Sub AppendResultSuggestion (text As String, detailText As String, tag As String, image As IRandomAccessStreamReference, imageAlternateText As String)

Parameters

text
String

Platform::String

winrt::hstring

The text of the suggested result.

detailText
String

Platform::String

winrt::hstring

The detail text for the suggested result.

tag
String

Platform::String

winrt::hstring

The unique tag that identifies this suggested result.

If this suggested result is selected by the user, a ResultSuggestionChosen event occurs. When the app handles this event, it can get the tag of the chosen result suggestion from the SearchPaneResultSuggestionChosenEventArgs.Tag property.

image
IRandomAccessStreamReference

The image to accompany the results suggestion. The image should be 40 x 40. Windows will scale or crop smaller or larger images.

imageAlternateText
String

Platform::String

winrt::hstring

The alternate text for the image.

Remarks

Important

To implement search in an app for Windows 10 or later, use AutoSuggestBox. See Auto-suggest box for more info.

You should not use Windows.ApplicationModel.Search APIs (SearchPane, SearchContract) or SearchBox APIs in apps for Windows 10 or later.

You should use result suggestions instead of query suggestions only to display high-confidence results that take the user directly to the item instead of to a view that shows search results.

Suggested results include an image and optional detail text to display with the suggestion in the search pane. The image signals to the user that they are seeing results and not query suggestions. If an image for the result doesn't exist, you can use a generic image or icon that represents the result or result type.

You must listen for and handle the ResultSuggestionChosen event if you want to provide result suggestions.

The search pane can display 5 suggestions, at most. Additionally, each separator you use takes the place of a suggestion and lowers the number of suggestions that you can display.

Applies to

See also