Share via


CommandBar.DefaultLabelPosition 屬性

定義

取得或設定值,指出命令列按鈕上標籤的位置和可見度。

public:
 property CommandBarDefaultLabelPosition DefaultLabelPosition { CommandBarDefaultLabelPosition get(); void set(CommandBarDefaultLabelPosition value); };
CommandBarDefaultLabelPosition DefaultLabelPosition();

void DefaultLabelPosition(CommandBarDefaultLabelPosition value);
public CommandBarDefaultLabelPosition DefaultLabelPosition { get; set; }
var commandBarDefaultLabelPosition = commandBar.defaultLabelPosition;
commandBar.defaultLabelPosition = commandBarDefaultLabelPosition;
Public Property DefaultLabelPosition As CommandBarDefaultLabelPosition
<CommandBar DefaultLabelPosition="commandBarDefaultLabelPositionMemberName" />

屬性值

列舉值,指出命令列按鈕上標籤的位置和可見度。 預設值為 Bottom

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

根據預設,應用程式行按鈕的標籤會顯示在圖示下方。 您可以設定此屬性以顯示圖示右邊的標籤,或隱藏標籤。

您可以設定 AppBarButton.LabelPosition 屬性來覆寫此值,並讓標籤一律折迭特定應用程式行按鈕。

版本相容性

在 Windows 10 1607 版之前,無法使用 DefaultLabelPosition 屬性。 如果您的 App 在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後的 [需求] 區塊中顯示的「引進版本」,您必須設計並測試您的應用程式以考慮此設定。 如需詳細資訊,請參閱 版本調適型程式碼

若要避免在舊版Windows 10上執行應用程式時發生例外狀況,請勿在 XAML 中設定此屬性,或在不執行執行時間檢查的情況下使用它。 此範例示範如何使用 ApiInformation 類別,在設定此屬性之前檢查此屬性是否存在。

<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
    ...
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.CommandBar", "DefaultLabelPosition"))
    {
        commandBar1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Right;
    }
}

適用於