LocalContentSuggestionSettings LocalContentSuggestionSettings LocalContentSuggestionSettings Class

Definition

Stores settings that determine whether the app provides suggestions based on local files, and that define the criteria used to locate and filter these suggestions.

public sealed class LocalContentSuggestionSettings : ILocalContentSuggestionSettingspublic sealed class LocalContentSuggestionSettings : ILocalContentSuggestionSettingsPublic NotInheritable Class LocalContentSuggestionSettings Implements ILocalContentSuggestionSettings
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The suggestions that the app provides are based on metadata fields and properties on the user's local, indexed files.

If enabled, local suggestions are displayed in the search pane when the user enters a query in the search box.

Disable these suggestions by setting the enabled property to false.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

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 Advanced Query Syntax (AQS) in .

Constructors

LocalContentSuggestionSettings() LocalContentSuggestionSettings() LocalContentSuggestionSettings()

Creates a new instance of the localContentSuggestionSettings class.

public LocalContentSuggestionSettings()public LocalContentSuggestionSettings()Public Sub New()
Attributes

Remarks

When you create a new localContentSuggestionSettings object, the enabled property is true by default.

See Also

Properties

AqsFilter AqsFilter AqsFilter

An Advanced Query Syntax (AQS) string that limits the types and kinds of files that are used to provide suggestions. If no Advanced Query Syntax (AQS) string is specified, suggestions are provided from all local files in locations specified by the locations property.

public string AqsFilter { get; set; }public string AqsFilter { get; set; }Public ReadWrite Property AqsFilter As string
Value
string string string

The Advanced Query Syntax (AQS) string that is used to refine which local, indexed files are used to provide suggestions. By default, this string is empty. Learn more about Advanced Query Syntax (AQS) in .

Attributes

Remarks

If local suggestions are disabled, this property has no effect. Set localContentSuggestionSettings.enabled property to true to display local suggestions in the search pane.

Use an AQS filter to help keep local suggestions relevant. For example, if your app is a video player, you may want to limit suggestions to videos or a specific file type.

Examples

The Search contract sample demonstrates how to use Advanced Query Syntax (AQS) to provide local suggestions from music files:

var localSuggestionSettings = new Windows.ApplicationModel.Search.LocalContentSuggestionSettings();
localSuggestionSettings.enabled = true;
localSuggestionSettings.locations.append(Windows.Storage.KnownFolders.musicLibrary);
localSuggestionSettings.aqsFilter = "kind:=music";
See Also

Enabled Enabled Enabled

Indicates whether suggestions based on local files are displayed in the search pane.

public bool Enabled { get; set; }public bool Enabled { get; set; }Public ReadWrite Property Enabled As bool
Value
bool bool bool

True if suggestions from local files are displayed; otherwise, false. The default value of the object is false.

Attributes
See Also

Locations Locations Locations

A list of the storageFolder objects that contain files that are used to provide suggestions. If the list is empty, suggestions are provided from files in all of the local libraries for which the app declared capabilities.

public IVector<StorageFolder> Locations { get; }public IVector<StorageFolder> Locations { get; }Public ReadOnly Property Locations As IVector<StorageFolder>
Value

The list of storageFolder locations that contain files that are used to provide suggestions. By default, this list is empty and suggestions are provided from the local files in all of the libraries for which the app declared capabilities.

Attributes

Remarks

If you add a location to the list, make sure you add all of the locations that contain files that you want used to provide local suggestions. If a location in this list is not valid, no suggestions are provided from that location. The remaining (valid) locations in this list are then used to provide suggestions.

Suggestions are provided based on local, indexed files in a listed storageFolder.

If local suggestions are disabled, this property has no effect. Set the localContentSuggestionSettings.enabled property to true to display local suggestions in the search pane.

You can use this list to provide suggestions from libraries or folders for which your app hasn't declared capabilities, like folders that were accessed using the file picker. Learn more about capabilities in Access to user resources using the Windows Runtime.

Examples

The Search contract sample demonstrates how to append a location to the list:

var localSuggestionSettings = new Windows.ApplicationModel.Search.LocalContentSuggestionSettings();
localSuggestionSettings.enabled = true;
localSuggestionSettings.locations.append(Windows.Storage.KnownFolders.musicLibrary);

If there is only one storageFolder in the locations list, like the Music library in the example, the local files in that location only are used to provide suggestions in the search pane.

See Also

PropertiesToMatch PropertiesToMatch PropertiesToMatch

A list of the file properties whose values are used to provide suggestions from local files. If the list is empty, all of the file properties that are available for suggestions are used.

public IVector<string> PropertiesToMatch { get; }public IVector<string> PropertiesToMatch { get; }Public ReadOnly Property PropertiesToMatch As IVector<string>
Value

The list of the file properties that are used to provide suggestions from local files. By default, this list is empty and all of the file properties that are available for suggestions are used.

Attributes

Remarks

If local suggestions are disabled, this property has no effect.

Adding properties to this list limits local suggestions to the values of the specified properties for local, indexed files. For example, if you want to limit suggestions to musical artists, you would append the "System.Music.AlbumArtist" (Album artists) or the "System.Music.Artist" (Contributing artists) property to the PropertiesToMatch list.

Adding properties to this list limits local suggestions to local, indexed files that have the listed properties.

See Also

See Also