【问题标题】:Application Bar for Windows Phone App is not showing in EmulatorWindows Phone 应用程序的应用程序栏未在模拟器中显示
【发布时间】:2014-12-18 13:00:18
【问题描述】:

我正在尝试为我的 Windows Phone Silverlight 应用程序创建一个应用程序栏。我已经多次检查过这段代码。我看没有错误。即使我检查了 MSDN 的网站。但是当我在模拟器上运行它时,应用程序栏没有显示。

我的代码有什么问题?

    <phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar Mode="Default"  Opacity="1.0" IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Assets/ApplicationBar/next.png" Text="Next" Click="appBar_next"/>
        <shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

这是完整的 XAML 代码:

<phone:PhoneApplicationPage
x:Class="Share_Bills.getPersonNum"
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">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="SHARE BILLS" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock Text="step 1" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="How many persons are you?" VerticalAlignment="Top" Margin="10,0,0,0" Height="53" Width="436"/>
        <TextBox x:Name="personNum" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap" VerticalAlignment="Top" Width="456" Margin="0,25,0,0" InputScope="Number"/>
        <Button x:Name="btnNext1" Content="Next" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="326,97,0,0" Width="130" Click="btnNext1_Click"/>
        <TextBlock x:Name="txtError" HorizontalAlignment="Left" Margin="10,102,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="311" Height="134"/>
    </Grid>

</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar Mode="Default"  Opacity="1.0" IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Assets/ApplicationBar/next.png" Text="Next" Click="appBar_next"/>
        <shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar></phone:PhoneApplicationPage>

【问题讨论】:

  • 您的项目中的 ApplicationBar XAML 在哪里?
  • 确定您的XAML 页面中有它吗?除此之外,您的代码似乎还可以。只需尝试更改 Mode 并删除 opacity 属性。
  • 我尝试更改模式和不透明度,但它不起作用!
  • 能否为页面添加其余的 xaml 代码,以便我们查看是否存在问题?
  • @ShahriarSirajSnigdho 嘿,您的完整 XAML 代码中 phone:PhoneApplicationPage 的关闭标记在哪里。我相信视觉工作室会给出错误The XML tag "phone:PhoneApplicationPage" is not closed. 添加结束标语后它工作正常(使用 applciationbar)。如果对您没有帮助,请创建示例应用并上传。

标签: c# xaml silverlight windows-phone-8 application-bar


【解决方案1】:

我编译了您的项目,它与 ApplicationBar 一起工作正常。最初您将项目入口点设置为MainPage.xaml,但您在代码中提到了getPersonNum.xaml 页面的问题。我跑了getPersonNum.xaml

这是我的模拟器的截图:

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 1970-01-01
    相关资源
    最近更新 更多