简体   繁体   中英

My ApplicationBar is not displayed

I created an application for Windows Phone 8 with "Visual Studio Express 2012 for Windows Phone". I have a first page to log in and after the user go to a pivot with 4 pivotItems where I want to add a ApplicationBar. I created my applicationBar and it is well displayed on my design. When I launch my app on the emulator or my phone the bar doesn't appear.

Do you have any ideas to solve my problems?

i have already made all the msdn tutorials concerning the applicationBar.

Thanks a lot!

This is my xaml code:

<phone:PhoneApplicationPage
    x:Class="DemoWP.Home"
    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:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,5,0,0">
        <phone:Pivot Margin="0,0,0,0" Foreground="#3399cc">
            <phone:PivotItem CacheMode="{x:Null}" Header="Accueil">
                <Grid/>
            </phone:PivotItem>
            <phone:PivotItem CacheMode="{x:Null}" Header="Planning" >
                <Grid/>
            </phone:PivotItem>
            <phone:PivotItem CacheMode="{x:Null}" Header="Site">
                <Grid/>
            </phone:PivotItem>
            <phone:PivotItem CacheMode="{x:Null}" Header="Contact">
                <Grid/>
            </phone:PivotItem>
        </phone:Pivot>
    </Grid>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity ="1.0" BackgroundColor="#3399cc" Mode="Default">
            <shell:ApplicationBarIconButton IconUri="/Images/feature.settings.png" Click="Settings_Click" Text="Paramètres"/>
            <shell:ApplicationBarIconButton IconUri="/Images/refresh.png" Click="Save_Click" Text="Actualiser"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="MenuItem1_Click" Text="Déconnexion"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>

And my c# code (very simple)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;



namespace DemoWP
{
    public partial class Home : PhoneApplicationPage
    {
        public Home()
        {
            InitializeComponent();

        }



        private void Save_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Save button works!");
            //Do work for your application here.
        }

        private void Settings_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Settings button works!");
            //Do work for your application here.
        }

        private void MenuItem1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Menu item 1 works!");
            //Do work for your application here.
        }

        private void MenuItem2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Menu item 2 works!");
            //Do work for your application here.
        }
    }
}

If it still isn't appearing in your emulator it may be some kind of bug within VS 2012. My suggestion would be to rebuild your project and then try and run it on the emulator again. That way you can be sure that your emulator is running your latest XAP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM