title: How to add icons to SecondaryCommands in Command Bar
body: <p>I am trying to build a CommandBar that looks like this:</p>
  
  <p>Desired CommandBar with SecondaryCommands that have icons
  <img src="https://i.stack.imgur.com/f4IP6.png" alt=""></p>
  
  <p>But I can't find a way to edit the default style of CommandOverflowPresenter in order to show SecondaryCommands like they are shown in Mail Windows 10 universal app, with icons on the left and text labels on the right.</p>
  
  <p>The CommandOverflowPresenter doesn't have a Content property to build a control template around it and bind content elements to AppBarButton Icon and Label properties.</p>
  
  <p>I found this <a href="https://pauliom.com/2015/12/05/951/" rel="nofollow noreferrer">article</a>, but it doesn't show the Style for the AppBarButton.</p>
  
  <p>There was another question on Stack Overflow, and the conclusion is to build a custom CommandOverflowPresenter style. How do you do that?</p>
  
  <p>Default CommandOverflowPresenter style:</p>
  
  <pre><code>&lt;!-- Default style for Windows.UI.Xaml.Controls.CommandBarOverflowPresenter --&gt;
  &lt;Style TargetType="CommandBarOverflowPresenter"&gt;
      &lt;Setter Property="Background" Value="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" /&gt;
      &lt;Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundChromeHighBrush}" /&gt;
      &lt;Setter Property="MaxWidth" Value="{ThemeResource CommandBarOverflowMaxWidth}"/&gt;
      &lt;Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" /&gt;
      &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /&gt;
      &lt;Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" /&gt;
      &lt;Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /&gt;
      &lt;Setter Property="ScrollViewer.ZoomMode" Value="Disabled" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="CommandBarOverflowPresenter"&gt;
                  &lt;Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"
                        BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,1" &gt;
                      &lt;VisualStateManager.VisualStateGroups&gt;
                          &lt;VisualStateGroup x:Name="DisplayModeStates"&gt;
                              &lt;VisualState x:Name="DisplayModeDefault" /&gt;
                              &lt;VisualState x:Name="FullWidthOpenDown" &gt;
                                  &lt;VisualState.Setters&gt;
                                      &lt;Setter Target="LayoutRoot.BorderThickness" Value="0,0,0,1" /&gt;
                                  &lt;/VisualState.Setters&gt;
                              &lt;/VisualState&gt;
                              &lt;VisualState x:Name="FullWidthOpenUp" &gt;
                                  &lt;VisualState.Setters&gt;
                                      &lt;Setter Target="LayoutRoot.BorderThickness" Value="0,1,0,0" /&gt;
                                  &lt;/VisualState.Setters&gt;
                              &lt;/VisualState&gt;
                          &lt;/VisualStateGroup&gt;
                      &lt;/VisualStateManager.VisualStateGroups&gt;
                      &lt;ScrollViewer
                          HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                          VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                          ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                          AutomationProperties.AccessibilityView="Raw"&gt;
                          &lt;ItemsPresenter x:Name="ItemsPresenter" Margin="0,7,0,7"/&gt;
                      &lt;/ScrollViewer&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>This is what I tried.</p>
  
  <p>CommandOverflowPresenter is an ItemsControl and I added a Setter for its ItemTemplate in CommandOverflowPresenter style, and let the Content template as it was in the default style. </p>
  
  <p>When running, the secondary commands are displayed according to the default style, only text labels are displayed, but not the icons. </p>
  
  <p>Perhaps the bindings are not set up properly in the ItemTemplate's DataTemplate?</p>
  
  <pre><code>&lt;CommandBar.CommandBarOverflowPresenterStyle&gt;
      &lt;Style TargetType="CommandBarOverflowPresenter"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="CommandBarOverflowPresenter"&gt;
                      &lt;Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,1" &gt;
  
                          &lt;!--&lt;Grid.Resources&gt;
                              &lt;DataTemplate x:Key="SecondaryMenu"&gt;
                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                      &lt;SymbolIcon Symbol="{TemplateBinding AppBarButton.Icon}"/&gt;
                                      &lt;TextBlock Text="{TemplateBinding AppBarButton.Label}" /&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/Grid.Resources&gt;--&gt;
  
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="DisplayModeStates"&gt;
                                  &lt;VisualState x:Name="DisplayModeDefault" /&gt;
                                  &lt;VisualState x:Name="FullWidthOpenDown" &gt;
                                      &lt;VisualState.Setters&gt;
                                          &lt;Setter Target="LayoutRoot.BorderThickness" Value="0,0,0,1" /&gt;
                                      &lt;/VisualState.Setters&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="FullWidthOpenUp" &gt;
                                      &lt;VisualState.Setters&gt;
                                          &lt;Setter Target="LayoutRoot.BorderThickness" Value="0,1,0,0" /&gt;
                                      &lt;/VisualState.Setters&gt;
                                  &lt;/VisualState&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
  
                          &lt;ScrollViewer
                              HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                              HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                              VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                              VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                              ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                              AutomationProperties.AccessibilityView="Raw"&gt;
                              &lt;ItemsPresenter x:Name="ItemsPresenter" Margin="0,7,0,7"&gt;
                              &lt;/ItemsPresenter&gt;
                          &lt;/ScrollViewer&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
  
          &lt;Setter Property="ItemTemplate"&gt;
              &lt;Setter.Value&gt;
                  &lt;DataTemplate x:DataType="AppBarButton"&gt;
                      &lt;StackPanel Orientation="Horizontal"&gt;
                          &lt;SymbolIcon Symbol="{Binding Icon}" /&gt;
                          &lt;TextBlock Text="{Binding Label}" /&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/CommandBar.CommandBarOverflowPresenterStyle&gt;
  </code></pre>
  
  <p>I also tried to add a StackPanel inside the AppBarButton tags with a SymbolIcon and a Textblock, but that didn't work either.</p>