SettingsCommand class

Applies to Windows only

Creates a settings command object that represents a settings entry. This settings command can be appended to the ApplicationCommands vector.

Syntax


public sealed class SettingsCommand : IUICommand

Attributes

[MarshalingBehavior(None)]
[Muse()]
[Version(0x06020000)]

Members

The SettingsCommand class has these types of members:

Constructors

The SettingsCommand class has these constructors.

ConstructorDescription
SettingsCommand Creates a new settings command.

 

Methods

The SettingsCommand class inherits methods from the Object class (C#/VB/C++).

Properties

The SettingsCommand class has these properties.

PropertyAccess typeDescription

AccountsCommand

Read-onlyGets the command for a web account in the account settings pane.

Id

Read/writeGets or sets the command ID.

Invoked

Read/writeGets or sets the handler for the event that is raised when the user selects the command.

Label

Read/writeGets or sets the label for the command.

 

Remarks

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 following code shows how to add app commands by using the SettingsPane and SettingsCommand classes. For the full example, see App settings sample.


using Windows.UI.ApplicationSettings;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using System;

// This is the click handler for the 'addSettingsScenarioAdd' button.  
// Replace this with your own handler if you have a button or buttons on this page.
void addSettingsScenarioAdd_Click(object sender, RoutedEventArgs e)
{
    Button b = sender as Button;
    if (b != null)
    {
        rootPage.NotifyUser(
            "You selected the " + b.Content + " button", 
            NotifyType.StatusMessage);

        if (!this.isEventRegistered)
        {
            SettingsPane.GetForCurrentView().CommandsRequested += onCommandsRequested;
            this.isEventRegistered = true;
        }
    }
}

void onSettingsCommand(IUICommand command)
{
    SettingsCommand settingsCommand = (SettingsCommand)command;
    rootPage.NotifyUser(
        "You selected the " + settingsCommand.Label + " settings command", 
        NotifyType.StatusMessage);
}

void onCommandsRequested(
    SettingsPane settingsPane, 
    SettingsPaneCommandsRequestedEventArgs eventArgs)
{
    UICommandInvokedHandler handler = new UICommandInvokedHandler(onSettingsCommand);

    SettingsCommand generalCommand = new SettingsCommand(
        "generalSettings", "General", handler);
    eventArgs.Request.ApplicationCommands.Add(generalCommand);

    SettingsCommand helpCommand = new SettingsCommand("helpPage", "Help", handler);
    eventArgs.Request.ApplicationCommands.Add(helpCommand);
}

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

None supported

Namespace

Windows.UI.ApplicationSettings
Windows::UI::ApplicationSettings [C++]

Metadata

Windows.winmd

See also

SettingsPane
App settings sample

 

 

Show:
© 2014 Microsoft