Skip to content

Instantly share code, notes, and snippets.

@martinsuchan
Created April 20, 2016 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinsuchan/dcbc58ef5f795dbd33480576690ea8d4 to your computer and use it in GitHub Desktop.
Save martinsuchan/dcbc58ef5f795dbd33480576690ea8d4 to your computer and use it in GitHub Desktop.
Broken SecondaryCommands when using AppBarButton->Style
<Page x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<SolidColorBrush x:Key="AppBarForegroundBrush" Color="DarkBlue"/>
<Style x:Key="MyAppBarButtonStyle" TargetType="AppBarButton">
<Setter Property="Foreground" Value="{StaticResource AppBarForegroundBrush}"/>
</Style>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="Open the Secondary buttons in BottomAppBar" TextWrapping="Wrap"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
</Grid>
<Page.BottomAppBar>
<CommandBar>
<CommandBar.PrimaryCommands>
<AppBarButton Label="Dummy" Icon="Edit"
Foreground="{StaticResource AppBarForegroundBrush}"/>
</CommandBar.PrimaryCommands>
<!-- This works as expected -->
<!-- <CommandBar.SecondaryCommands>
<AppBarButton Label="Short"
Foreground="{StaticResource AppBarForegroundBrush}"/>
<AppBarButton Label="LongerLabel"
Foreground="{StaticResource AppBarForegroundBrush}"/>
<AppBarButton Label="SuperLongLabel"
Foreground="{StaticResource AppBarForegroundBrush}"/>
</CommandBar.SecondaryCommands>-->
<!-- This crops labels for Secondary Commands, see https://imgur.com/Wt72LU5 -->
<CommandBar.SecondaryCommands>
<AppBarButton Label="Short"
Style="{StaticResource MyAppBarButtonStyle}"/>
<AppBarButton Label="LongerLabel"
Style="{StaticResource MyAppBarButtonStyle}"/>
<AppBarButton Label="SuperLongLabel"
Style="{StaticResource MyAppBarButtonStyle}"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment