How can i add AppBar in Windows Phone 8.1

后端 未结 3 1580
不思量自难忘°
不思量自难忘° 2021-02-19 05:21

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

相关标签:
3条回答
  • 2021-02-19 05:51

    Create Class with Method

    public static void AddNewAppBarinPage(Page myPage)
    {
       CommandBar cbar = new CommandBar { ClosedDisplayMode = AppBarClosedDisplayMode.Minimal };
       AppBarButton appBarButton = new AppBarButton { Label = "Audio" };
       cbar.PrimaryCommands.Add(appBarButton);
       myPage.BottomAppBar = cbar;
    }
    

    use in Page:

    AppBarCustom.AddNewAppBarinPage(this);
    
    0 讨论(0)
  • 2021-02-19 06:10

    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!

    0 讨论(0)
  • 2021-02-19 06:10

    Here's another way. Scroll all the way to the top of the XAML afterwards, click on the first text/string <phone:PhoneApplicationPage you can either press F4 in order to bring up the "Common" selection or you can just click on it and just go to properties and press "Common" and there you will see a new option called "ApplicationBar". This way is much better, you can create a new fresh one this way.

    0 讨论(0)
提交回复
热议问题