AppBarButton.LabelPosition Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates the placement and visibility of the button's label.
public:
property CommandBarLabelPosition LabelPosition { CommandBarLabelPosition get(); void set(CommandBarLabelPosition value); };
CommandBarLabelPosition LabelPosition();
void LabelPosition(CommandBarLabelPosition value);
public CommandBarLabelPosition LabelPosition { get; set; }
var commandBarLabelPosition = appBarButton.labelPosition;
appBarButton.labelPosition = commandBarLabelPosition;
Public Property LabelPosition As CommandBarLabelPosition
<AppBarButton LabelPosition="commandBarLabelPositionMemberName" />
Property Value
An enumeration value that specifies the placement and visibility of the button's label. The default is Default.
Remarks
By default, the app bar button's label is displayed in the position specified by the CommandBar.DefaultLabelPosition property. You can set the LabelPosition property to override this value and make the label always collapsed for a specific app bar button.
Version compatibility
The LabelPosition property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.
To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.
<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
<AppBarButton x:Name="appBarButtonCut" Icon="Cut" Label="Cut"/>
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.AppBarButton", "LabelPosition"))
{
appBarButtonCut.LabelPosition = CommandBarLabelPosition.Collapsed;
}
}