Search code examples
.netmobilewindows-phone-8windows-phonewindows-phone-8.1

How can i add AppBar in Windows Phone 8.1


In windows phone 8, its very easy to add an App Bar and manage it, but now i test new windows phone 8.1 SDK to build a project with new Geofencing feature but i don't know how to add an App Bar in the App.


Solution

  • In Windows Phone 8.1, We can use BottomAppBar to add App Bar. Usually we use CommandBar to create basic BottomAppBar. CommandBar contains two collection: PrimaryCommands and SecondaryCommands, It's similar with shell:ApplicationBar.Buttons and shell:ApplicationBar.MenuItems in Windows Phone 8.

    Read this demo please, we create a CommandBar with two buttons: ZoomOut and ZoomIn, and two menuItem:Test01 and Test02 :

    <Page.BottomAppBar>
        <CommandBar IsSticky="True" x:Name="appBar">
            <CommandBar.PrimaryCommands>
                <AppBarButton Icon="ZoomOut" IsCompact="False" Label="ZoomOut"/>
                <AppBarButton Icon="ZoomIn" IsCompact="False" Label="ZoomIn"/>
            </CommandBar.PrimaryCommands>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Test01"/>
                <AppBarButton Label="Test02"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
    

    Edit: Now the code is correct!