LocalContentSuggestionSettings LocalContentSuggestionSettings LocalContentSuggestionSettings LocalContentSuggestionSettings Class

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.

Syntax

Declaration

public sealed class LocalContentSuggestionSettingspublic sealed class LocalContentSuggestionSettingsPublic NotInheritable Class LocalContentSuggestionSettingspublic sealed class LocalContentSuggestionSettings

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 summary

Creates a new instance of the LocalContentSuggestionSettings class.

Properties summary

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.

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

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.

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.

Constructors

  • LocalContentSuggestionSettings()
    LocalContentSuggestionSettings()
    LocalContentSuggestionSettings()
    LocalContentSuggestionSettings()

    Creates a new instance of the LocalContentSuggestionSettings class.

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

    Remarks

    When you create a new LocalContentSuggestionSettings object, the Enabled property is true by default.

Properties

  • AqsFilter
    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 stringpublic string AqsFilter { get; set; }

    Property Value

    • string
      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 .

    Remarks

    If local suggestions are disabled, this property has no effect. Set 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";
    
  • Enabled
    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 boolpublic bool Enabled { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

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

  • Locations
    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>public IVector<StorageFolder> Locations { get; }

    Property 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.

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

  • PropertiesToMatch
    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>public IVector<string> PropertiesToMatch { get; }

    Property 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.

    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.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.ApplicationModel.Search.dll