繁体   English   中英

如何在Windows Phone 7中将应用程序栏设置为不显示或在其他页面中显示其他按钮?

[英]How to set the Application Bar no to be displayed or to show another buttons in different pages in Windows Phone 7?

当我发现即使在XAML中设置不同的应用程序栏也不会使它在不同的应用程序页面中更改时,我在弄乱Windows Phone 7应用程序栏(我不得不说这很烦人)。 我的意图是使用带有一些按钮的此栏,这些按钮会根据正在显示的页面而变化,比如说,在主菜单中,它不会显示主菜单图标,但是在另一个页面中,它将显示。 你们能帮我些忙吗?

第1页:

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="Icons/mainmenu.png" Text="Main Menu"  />
                <shell:ApplicationBarIconButton IconUri="Icons/list.png" Text="Comic List"  />
                <shell:ApplicationBarIconButton IconUri="Icons/settings.png" Text="Settings"  IsEnabled="True" x:Name="ApplicationBarUploadIconButton" />
            </shell:ApplicationBar.Buttons>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

第2页:

<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="Icons/settings.png" Text="Settings"  />
                <shell:ApplicationBarIconButton IconUri="Icons/list.png" Text="Comic List"  />
                <shell:ApplicationBarIconButton IconUri="Icons/download.png" Text="Download Comic"  IsEnabled="True" x:Name="ApplicationBarUploadIconButton" />
            </shell:ApplicationBar.Buttons>

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

第3页:

 <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="False" IsMenuEnabled="False">
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

应用程序栏始终是相同的,并且始终显示(即使第3页中的显式声明没有显示出来)。

提前致谢!

您可以使用控件的SelectionChanged事件来检查页面的selectedindex ...

private void Panorama_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if(panaroma.SelectedIndex == 1) //Your required page index
            ApplicationBar.IsVisible = true;
        else
            ApplicationBar.IsVisible = false; // other pages will be hidden            
    }

实际上,在各个页面上的应用程序栏中确实可以有不同数量的按钮。 如果您在页面上添加了应用程序栏,并在每个页面中看到4个空的圆形区域,则无需担心-它仅是设计器视图。 举例来说,在MainPage.xaml ,您可以拥有一个像这样的应用程序栏-

<phone:PhoneApplicationPage.ApplicationBar>
  <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.refresh.rest.png" 
                                     Text="Refresh"
                                     Click="RefreshPage_Click" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

DetailsPage.xaml页面中,您可以拥有一个类似这样的应用程序栏-

<phone:PhoneApplicationPage.ApplicationBar>
  <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.home.png" 
                                     Text="Home"
                                     Click="GoBackHome_Click" />
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.next.rest.png" 
                                     Text="Next"
                                     Click="NextPage_Click" />
     <shell:ApplicationBarIconButton IconUri="/Images/appbar.previous.rest.png" 
                                     Text="Next"
                                     Click="PreviousPage_Click" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

HTH,indyfromoz

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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