Creates a settings command object that represents a settings entry. This settings command can be appended to the ApplicationCommands vector.
Syntax
var settingsCommand = new Windows.UI.ApplicationSettings.SettingsCommand();
Attributes
- ActivatableAttribute(Windows.UI.ApplicationSettings.ISettingsCommandFactory, NTDDI_WIN8)
- MarshalingBehaviorAttribute(None)
- MuseAttribute()
- VersionAttribute(NTDDI_WIN8)
Members
The SettingsCommand class has these types of members:
Constructors
The SettingsCommand class has these constructors.
| Constructor | Description |
|---|---|
| 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.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets or sets the command ID. | |
| Read/write | Gets or sets the handler for the event that is raised when the user selects the command. | |
| Read/write | Gets 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] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 12/4/2012