AccountsSettingsPane 類別

定義

提供顯示帳戶窗格的方法,以及讓應用程式在即將顯示帳戶飛出視窗時註冊回呼。

public ref class AccountsSettingsPane sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
class AccountsSettingsPane final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
public sealed class AccountsSettingsPane
Public NotInheritable Class AccountsSettingsPane
繼承
Object Platform::Object IInspectable AccountsSettingsPane
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

應用程式會針對應用程式顯示的所有 Web 帳戶提供者、Web 帳戶、通用帳戶命令和認證保險箱認證,提供帳戶中繼資料的回呼。 帳戶提供者的範例包括 Facebook、LinkedIn和 Twitter。

Windows.UI.ApplicationSettings命名空間中的帳戶和認證命令類別會對應至Windows.UI.ApplicationSettings命名空間中的資料物件:

Data Object (Windows.Security.Credentials) UI 物件 (Windows.UI.ApplicationSettings)
WebAccount WebAccountCommand
WebAccountProvider WebAccountProviderCommand
PasswordCredential CredentialCommand

傳統型應用程式

針對傳統型應用程式,您必須使用 Interop API,而不是使用 AccountSettingsPane 類別,如下所示。

以下是如何在 C# 中使用 AccountSettingsPaneInterop 類別的範例 (.NET 6 或更新版本) :

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
    // Retrieve the window handle for whichever UI framework being used (WinUI 3, WPF, WinForms)
    var hwnd = ...
    // Call methods from the interop class, passing in the window handle
    await AccountsSettingsPaneInterop.ShowManageAccountsForWindowAsync(hwnd);
}

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 ShowAddAccountAsync
1607 14393 ShowManageAccountsAsync
1803 17134 ShowAddAccountForUserAsync
1803 17134 ShowManageAccountsForUserAsync

方法

GetForCurrentView()

取得與目前應用程式檢視相關聯的 AccountsSettingsPane 物件 (,也就是 CoreWindow) 。

Show()

顯示 [帳戶設定] 窗格。

ShowAddAccountAsync()

顯示 [新增帳戶] 畫面。

ShowAddAccountForUserAsync(User)

顯示指定使用者的 [新增帳戶] 畫面。

ShowManageAccountsAsync()

顯示 [管理帳戶] 畫面。

ShowManageAccountsForUserAsync(User)

顯示指定使用者的 [管理帳戶] 畫面。

事件

AccountCommandsRequested

發生于使用者開啟帳戶窗格時。 處理此事件可讓應用程式初始化帳戶命令,並暫停其 UI,直到使用者關閉窗格為止。

適用於

另請參閱