CommandBar Control in UWP

CommandBar represents a specialized app bar that provides layout for AppBarButton and related command elements.

Step 1: Open a blank app and copy the following XAML code into your grid which have corresponding controls.

  1. <CommandBar>  
  2.    <AppBarButton Icon="Back" Label="Back" />  
  3.    <AppBarButton Icon="Stop" Label="Stop" />  
  4.    <AppBarButton Icon="Play" Label="Play" />  
  5.    <AppBarButton Icon="Forward" Label="Forward" />  
  7.    <CommandBar.SecondaryCommands>  
  8.       <AppBarButton Icon="Like" Label="Like" />  
  9.       <AppBarButton Icon="Dislike" Label="Dislike" />  
  10.    </CommandBar.SecondaryCommands>  
  12.    <CommandBar.Content>  
  13.       <TextBlock Text="Now playing..." Margin="12,14"/>  
  14.    </CommandBar.Content>  
  15. </CommandBar>       

Use a CommandBar to provide users with quick access to your app’s most common tasks. It's a general-purpose, flexible, light-weight control that can display both complex content, such as images, progress bars, or text blocks, as well as simple commands such as AppBarButton, AppBarToggleButton, and AppBarSeparator controls.

CommandBar has three properties you can use to add content and commands: Content, PrimaryCommands, and SecondaryCommands. You can add any XAML elements to the content area by setting the Content property.

Step 2: Run your application and test yourself.

Ebook Download
View all
View all