SearchBox.SetLocalContentSuggestionSettings method

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

Syntax


public void SetLocalContentSuggestionSettings(
  LocalContentSuggestionSettings settings
)

Parameters

settings

Type: LocalContentSuggestionSettings

The new settings for local content suggestions.

Remarks

When local content suggestions are enabled, Windows provides 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.

To search a local library, the appropriate capability must be declared in the app manifest. For more info, see App capability declarations.

Examples

Here, suggestions are restricted to one kind of file, music files, using an AQS string. Two of the most common 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.


public MainPage()
{
    this.InitializeComponent();

    // Let Windows provide suggestions from local files.
    var settings = new Windows.ApplicationModel.Search.LocalContentSuggestionSettings();
    settings.Enabled = true;
    // Access to the music library requires that the Music Library capability
    // be declared in the app manifest .
    settings.Locations.Add(Windows.Storage.KnownFolders.MusicLibrary);
    settings.AqsFilter = "kind:Music";
    MySearchBox.SetLocalContentSuggestionSettings(settings);
}


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

None supported

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

SearchBox

 

 

Show:
© 2015 Microsoft