Posted by: Zeeshan Amjad | October 21, 2012

Define styles for AppBar buttons


We already saw the usage of few standard styles in AppBar button here. StandardStyles.xaml already defined lots of styles. Here is one example from the StandardStyles.xaml file.

Code Snippet
<Style x:Key="SettingsAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="SettingsAppBarButton"/>
    <Setter Property="AutomationProperties.Name" Value="Settings"/>
    <Setter Property="Content" Value=""/>
</Style>

 

But we how do I know the look and feel of this style. The easiest way to see this is open the Windows Character map and type Segoe UI Symbol from the Font combo box and here you will see all the symbols as shown in the screen shot.

CharacterMap

In same way we can define our own styles, just by looking at the character map. Here is one style we defined that is not present in StandardStyles.xaml file.

Code Snippet
<Style x:Key="WatchAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="WatchAppBarButton"/>
    <Setter Property="AutomationProperties.Name" Value="Watch"/>
    <Setter Property="Content" Value="⌚"/>
</Style>

 

Let’s see how it looks like when used in AppBar.

Code Snippet
<Page.BottomAppBar>
    <AppBar>
        <StackPanel Orientation="Horizontal">
            <Button Style="{StaticResource WatchAppBarButtonStyle}"/>
        </StackPanel>
    </AppBar>
</Page.BottomAppBar>

 

Here is the output of this program.

AppBarDemo_05

There is nothing specific to Segoe UI Symbol. We can define the style for any type of font. Here is one example to define style for another symbol which is not in Segoe UI Symbol.

Code Snippet
<Style x:Key="AllahAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="AllahAppBarButton"/>
    <Setter Property="AutomationProperties.Name" Value="Allah"/>
    <Setter Property="Content" Value="ﷲ"/>
</Style>

 

And here is its output.

AppBarDemo_06

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: