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 NotInheritable Class SettingsCommand
    Implements 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.

Imports Windows.UI.ApplicationSettings
Imports Windows.UI.Popups
Imports Windows.UI.Xaml
Imports Windows.UI.Xaml.Controls
Imports Windows.UI.Xaml.Navigation
Imports 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.
    Private Sub addSettingsScenarioAdd_Click(sender As Object, e As RoutedEventArgs)
        Dim b As Button = TryCast(sender, Button)
        If b IsNot Nothing Then
            rootPage.NotifyUser("You selected the " & b.Content & " button", _
                NotifyType.StatusMessage)
            If Not Me.isEventRegistered Then
                AddHandler SettingsPane.GetForCurrentView.CommandsRequested, _
                    AddressOf onCommandsRequested
                Me.isEventRegistered = True
            End If
        End If
    End Sub

    Private Sub onSettingsCommand(command As IUICommand)
        Dim settingsCommand As SettingsCommand = DirectCast(command, SettingsCommand)
        rootPage.NotifyUser( _
        "You selected the " & settingsCommand.Label & " settings command", _
        NotifyType.StatusMessage)
    End Sub

    Private Sub onCommandsRequested(settingsPane As SettingsPane, _
        eventArgs As SettingsPaneCommandsRequestedEventArgs)
        Dim handler As New UICommandInvokedHandler(AddressOf onSettingsCommand)

        Dim generalCommand As New SettingsCommand("generalSettings", "General", handler)
        eventArgs.Request.ApplicationCommands.Add(generalCommand)

        Dim helpCommand As New SettingsCommand("helpPage", "Help", handler)
        eventArgs.Request.ApplicationCommands.Add(helpCommand)
    End Sub


    '' This is the click handler for the 'addSettingsScenarioShow' button.  
    '' Replace this with your own handler if you have a button or buttons on this page.
    Private Sub addSettingsScenarioShow_Click(sender As Object, e As RoutedEventArgs)
        Dim b As Button = TryCast(sender, Button)
        If b IsNot Nothing Then
            rootPage.NotifyUser("You selected the " & b.Content & " button", _
                NotifyType.StatusMessage)
            SettingsPane.Show()
        End If
    End Sub

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