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 ref class SettingsCommand sealed : 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.


#include "pch.h"
#include "AddSettingsScenario.xaml.h"

using namespace ApplicationSettings;

using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::ApplicationSettings;
using namespace Windows::UI::Popups;

void ApplicationSettings::AddSettingsScenario::addSettingsScenarioAdd_Click(
    Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    Button^ b = safe_cast<Button^>(sender);
    if (b != nullptr)
    {
        rootPage->NotifyUser("You selected the " + b->Content + " button", 
            NotifyType::StatusMessage);
        if (!this->isEventRegistered)
        {
            this->commandsRequestedEventRegistrationToken = 
                SettingsPane::GetForCurrentView()->CommandsRequested += 
                    ref new TypedEventHandler<SettingsPane^, 
                    SettingsPaneCommandsRequestedEventArgs^>(this, 
                        &AddSettingsScenario::onCommandsRequested);
            this->isEventRegistered = true;
        }
    }
}

void ApplicationSettings::AddSettingsScenario::onSettingsCommand(
    Windows::UI::Popups::IUICommand^ command)
{
    SettingsCommand^ settingsCommand = safe_cast<SettingsCommand^>(command);
    rootPage->NotifyUser(
        "You selected the " + settingsCommand->Label + " settings command", 
        NotifyType::StatusMessage);
}

void ApplicationSettings::AddSettingsScenario::onCommandsRequested(
    Windows::UI::ApplicationSettings::SettingsPane^ settingsPane,
    Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs^ eventArgs)
{
    UICommandInvokedHandler^ handler = ref new UICommandInvokedHandler(
        this, &AddSettingsScenario::onSettingsCommand);

    SettingsCommand^ generalCommand = ref new SettingsCommand(
        "generalSettings", "General", handler);
    eventArgs->Request->ApplicationCommands->Append(generalCommand);

    SettingsCommand^ helpCommand = ref new SettingsCommand("helpPage", "Help", handler);
    eventArgs->Request->ApplicationCommands->Append(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