没有显示我的应用程序栏

本文关键字:应用程序 我的 显示 | 更新日期: 2023-09-27 18:06:16

我用"Visual Studio Express 2012 for Windows Phone"创建了一个Windows Phone 8应用程序。我有一个登录的第一页,用户去一个pivot与4个pivotItems,我想添加一个ApplicationBar后。我创建了我的应用程序栏,它很好地显示在我的设计上。当我在模拟器或手机上启动我的应用程序时,这个栏不会出现。

你有什么办法可以解决我的问题吗?

我已经制作了所有关于applicationBar的msdn教程。

非常感谢!

这是我的xaml代码:
<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>

和我的c#代码(非常简单)

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.
        }
    }
}

没有显示我的应用程序栏

如果它仍然没有出现在你的模拟器中,它可能是VS 2012中的某种bug。我的建议是重新构建您的项目,然后再次尝试在模拟器上运行它。这样您就可以确保您的模拟器正在运行最新的XAP。