SearchPane.SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SearchPane.SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SearchPane.SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SearchPane.SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SearchPane.SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) Method

Definition

Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that Windows uses to locate and filter these suggestions.

public : void SetLocalContentSuggestionSettings(LocalContentSuggestionSettings settings)
void SetLocalContentSuggestionSettings(LocalContentSuggestionSettings settings) const;
public void SetLocalContentSuggestionSettings(LocalContentSuggestionSettings settings)
Public Sub SetLocalContentSuggestionSettings(settings As LocalContentSuggestionSettings)
searchPane.setLocalContentSuggestionSettings(settings);

Parameters

settings
LocalContentSuggestionSettings LocalContentSuggestionSettings LocalContentSuggestionSettings

The new settings for local content suggestions.

Examples

The Search contract sample demonstrates how to customize local suggestions by restricting the locations and kinds of files that the suggestions are based on.

Tip

You should add this code to your app's global scope and run it as soon as your app is launched.

// Have Windows provide suggestions from local files.
// This code should be placed in your apps global scope and run as soon as your app is launched.
var settings = new LocalContentSuggestionSettings();
settings.Enabled = true;
if (isLocal)
{
    settings.Locations.Add(KnownFolders.MusicLibrary);
    settings.AqsFilter = "kind:Music";
}
SearchPane.GetForCurrentView().SetLocalContentSuggestionSettings(settings);
var settings = new Windows.ApplicationModel.Search.LocalContentSuggestionSettings();
settings.enabled = true;
settings.locations.append(Windows.Storage.KnownFolders.musicLibrary);
settings.aqsFilter = "kind:=music";

Windows.ApplicationModel.Search.SearchPane.getForCurrentView().setLocalContentSuggestionSettings(settings);

In the example, suggestions are restricted to one kind of file, music files, using an Advanced Query Syntax (AQS) string. Two of the most common Advanced Query Syntax (AQS) filters restrict based on file kind, like "kind:=.music" in the example; and based on file name extension, like "ext:=.mp3". You can learn more about AQS in Advanced Query Syntax (AQS).

Remarks

Note

An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for UWP app using C++, C#, or Visual Basic, WinJS.UI.SearchBox for Windows app using JavaScript) and the SearchPane. Using both the search box and the search pane in the same app causes the app to throw an exception with this message: "Cannot create instance of type 'Windows.UI.Xaml.Controls.SearchBox.'"

When local content suggestions are enabled, Windows will provide search suggestions from the user's local files as the user enters query text. For example, a picture application can configure local content suggestions so that search suggestions come only from a particular kind of image file that is stored in the user's picture library.

See also