Application Bar Sample

This sample demonstrates how you can test app bar properties, including opacity, color, and mode, in a plain page, a pivot page, and a panorama page.

 
 
 
 
 
4.6 Star
(5)
20,624 times
Add to favorites
3/5/2013
E-mail Twitter del.icio.us Digg Facebook
<!-- 
    Copyright (c) 2011 Microsoft Corporation.  All rights reserved.
    Use of this sample source code is subject to the terms of the Microsoft license 
    agreement under which you licensed this sample source code and is provided AS-IS.
    If you did not accept the terms of the license agreement, you are not authorized 
    to use this sample source code.  For the terms of the license, please see the 
    license agreement between you and Microsoft.
    
    To see all Code Samples for Windows Phone, visit http://go.microsoft.com/fwlink/?LinkID=219604
-->
<phone:PhoneApplicationPage 
    x:Class="sdkAppBarCS.PivotPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <!--Pivot Control-->
        <controls:Pivot Title="pivot page">

            <!--Pivot item one-->
            <controls:PivotItem Header="piv 1">
                <ScrollViewer x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                    <StackPanel>

                        <TextBlock Text="foreground color" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="ForeColorChanged" Name="ForeNormal" Content="normal" />
                            <RadioButton Checked="ForeColorChanged" Name="ForeAccent" Content="accent" />
                        </StackPanel>

                        <TextBlock Text="background color" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="BackColorChanged" Name="BackNormal" Content="normal" />
                            <RadioButton Checked="BackColorChanged" Name="BackAccent" Content="accent" />
                        </StackPanel>

                        <TextBlock Text="opacity" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="OpacityChanged" Name="One" Content="1.0" />
                            <RadioButton Checked="OpacityChanged" Name="Half" Content="0.5" />
                            <RadioButton Checked="OpacityChanged" Name="Zero" Content="0.0" />
                        </StackPanel>

                        <TextBlock Text="size mode (NEW PROPERTY!)" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="ModeChanged" Name="DefaultSize" Content="default" />
                            <RadioButton Checked="ModeChanged" Name="Mini" Content="mini" />
                        </StackPanel>

                        <TextBlock Text="menu items" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="MenuEnabledChanged" Name="Enabled" Content="enabled" />
                            <RadioButton Checked="MenuEnabledChanged" Name="Disabled" Content="disabled" />
                        </StackPanel>

                        <TextBlock Text="visibility" Foreground="{StaticResource PhoneAccentBrush}" />
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Checked="VisibilityChanged" Name="Visible" Content="visible" />
                            <RadioButton Checked="VisibilityChanged" Name="Hidden" Content="hidden" />
                        </StackPanel>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="piv 2">
                <StackPanel>
                    <TextBlock Text="p2"/>
                </StackPanel>
            </controls:PivotItem>

            <!--Pivot item three-->
            <controls:PivotItem Header="piv 3">
                <StackPanel>
                    <TextBlock Text="p3"/>
                </StackPanel>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Default" Opacity="1.0" >

            <shell:ApplicationBarIconButton IconUri="/Images/save.png" Text="save" Click="Button1_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/delete.png" Text="delete" Click="Button2_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/help.png" Text="help" Click="Button3_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/settings.png" Text="settings" Click="Button4_Click" />

            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="get default size value" Click="MenuItem1_Click" />
                <shell:ApplicationBarMenuItem Text="get mini size value" Click="MenuItem2_Click" />
            </shell:ApplicationBar.MenuItems>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>