AppBarToggleButton.LabelPosition 屬性

定義

取得或設定值,這個值表示按鈕標籤的位置和可見度。

public:
 property CommandBarLabelPosition LabelPosition { CommandBarLabelPosition get(); void set(CommandBarLabelPosition value); };
CommandBarLabelPosition LabelPosition();

void LabelPosition(CommandBarLabelPosition value);
public CommandBarLabelPosition LabelPosition { get; set; }
var commandBarLabelPosition = appBarToggleButton.labelPosition;
appBarToggleButton.labelPosition = commandBarLabelPosition;
Public Property LabelPosition As CommandBarLabelPosition
<AppBarToggleButton LabelPosition="commandBarLabelPositionMemberName" />

屬性值

列舉值,指定按鈕標籤的位置和可見度。 預設值為 Default

Windows 需求

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

備註

根據預設,應用程式行按鈕的標籤會顯示在 CommandBar.DefaultLabelPosition 屬性所指定的位置。 您可以設定 LabelPosition 屬性來覆寫此值,並讓標籤一律折迭特定應用程式行按鈕。

版本相容性

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

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

<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
    <AppBarToggleButton x:Name="appBarButtonShuffle" Icon="Shuffle" Label="Shuffle"/>
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.AppBarToggleButton", "LabelPosition"))
    {
        appBarButtonShuffle.LabelPosition = CommandBarLabelPosition.Collapsed;
    }
}

適用於