SettingsPane Класс

Определение

Примечание

SettingsPane является нерекомендуемой и может работать не во всех версиях Windows 10. Вместо использования SettingsPane интегрируйте параметры параметров в интерфейс приложения. Дополнительные сведения см. в разделе Рекомендации по параметрам приложения.

Статический класс, который позволяет приложению управлять панелью чудо-кнопки "Параметры". Приложение может добавлять или удалять команды, получать уведомления, когда пользователь открывает панель, или открывать ее программным способом.

public ref class SettingsPane sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.UI.ApplicationSettings.ApplicationsSettingsContract, 65536)]
/// [Windows.Foundation.Metadata.Deprecated("SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.UI.ApplicationSettings.ApplicationsSettingsContract)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
class SettingsPane final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.UI.ApplicationSettings.ApplicationsSettingsContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
/// [Windows.Foundation.Metadata.Deprecated("SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.UI.ApplicationSettings.ApplicationsSettingsContract")]
class SettingsPane final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.UI.ApplicationSettings.ApplicationsSettingsContract), 65536)]
[Windows.Foundation.Metadata.Deprecated("SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.UI.ApplicationSettings.ApplicationsSettingsContract))]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
public sealed class SettingsPane
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.UI.ApplicationSettings.ApplicationsSettingsContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
[Windows.Foundation.Metadata.Deprecated("SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.UI.ApplicationSettings.ApplicationsSettingsContract")]
public sealed class SettingsPane
Public NotInheritable Class SettingsPane
Наследование
Object Platform::Object IInspectable SettingsPane
Атрибуты

Требования к Windows

Семейство устройств
Windows Desktop Extension SDK (появилось в 10.0.10240.0)
Xbox One Extensions for the UWP (появилось в 10.0.10586.0)
API contract
Windows.UI.ApplicationSettings.ApplicationsSettingsContract (появилось в v1.0)

Примеры

В следующем коде показано, как добавлять команды приложения с помощью классов SettingsPane и SettingsCommand . Полный пример см. в разделе Пример параметров приложения.

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 from the " + 
        SettingsPane.Edge.ToString(), 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);
}
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 & " command from the " & SettingsPane.Edge.ToString(), _
        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
#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 from the " + 
        SettingsPane::Edge.ToString(), 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);
}

Комментарии

Примечание

Этот класс не является гибким. Это означает, что необходимо учитывать его модель потоков и поведение маршалинга. Дополнительные сведения см. в разделах Потоки и маршалинг (C++/CX) и Использование среда выполнения Windows объектов в многопоточной среде (.NET).

Свойства

Edge

Примечание

SettingsPane является нерекомендуемой и может работать не во всех версиях Windows 10. Вместо использования SettingsPane интегрируйте параметры параметров в интерфейс приложения. Дополнительные сведения см. в разделе Рекомендации по параметрам приложения.

Возвращает значение, указывающее, отображается ли чудо-кнопка "Параметры" на левом или правом крае экрана.

Методы

GetForCurrentView()

Примечание

SettingsPane является нерекомендуемой и может работать не во всех версиях Windows 10. Вместо использования SettingsPane интегрируйте параметры параметров в интерфейс приложения. Дополнительные сведения см. в разделе Рекомендации по параметрам приложения.

Возвращает объект SettingsPane , связанный с текущим представлением приложения (то есть с CoreWindow).

Show()

Примечание

SettingsPane является нерекомендуемой и может работать не во всех версиях Windows 10. Вместо использования SettingsPane интегрируйте параметры параметров в интерфейс приложения. Дополнительные сведения см. в разделе Рекомендации по параметрам приложения.

Отображает панель чудо-кнопки "Параметры" для пользователя.

События

CommandsRequested

Примечание

SettingsPane является нерекомендуемой и может работать не во всех версиях Windows 10. Вместо использования SettingsPane интегрируйте параметры параметров в интерфейс приложения. Дополнительные сведения см. в разделе Рекомендации по параметрам приложения.

Происходит, когда пользователь открывает панель параметров. Прослушивание этого события позволяет приложению инициализировать команды параметров и приостанавливать пользовательский интерфейс, пока пользователь не закроет панель.

Во время этого события добавьте объекты SettingsCommand в доступный вектор ApplicationCommands , чтобы сделать их доступными в пользовательском интерфейсе SettingsPane.

Применяется к

См. также раздел