我使用“Visual Studio Express 2012 for Windows Phone”为 Windows Phone 8 创建了一个应用程序。我有一个要登录的第一页,并且在用户转到带有 4 个 pivotItems 的枢轴之后,我想在其中添加一个 ApplicationBar。我创建了我的 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.
}
}
}