Windows 8 导航后应用程序栏不工作
我正在 Windows 8 上开发简单的应用程序。
我有两个用户控件:Locations 和 LocationsMap。
我正在尝试在它们之间导航。为此,我已将静态方法添加到 App.他们就像这样
public static void ShowLocationsMap()
{
var page = new LocationsMap();
Window.Current.Content = page;
}
导航工作正常。 但有一个问题。我从 ApplicationBar 中的按钮调用此方法。 XAML 看起来像这样
<ApplicationBar x:Name="BottomAppBar" Height="88" VerticalAlignment="Bottom" Style="{StaticResource AppBarStyle}" Grid.Row="1">
<StackPanel Orientation="Horizontal">
<!-- Margin="left,top,right,bottom" -->
<StackPanel Orientation="Vertical" Margin="5,14,5,14">
<Button Content="Map" Click="MapButton_Click"></Button>
</StackPanel>
</StackPanel>
</ApplicationBar>
,我通过调用下一页的其他函数来导航回来。
问题是,当我返回时,ApplicationBar 停止工作。右键后不显示。如果我将 BottomAppBar.IsOpen 设置为 true,它会显示,但不会关闭。
问题出在哪里?
PS
当我从控件 XAML 上的按钮导航到其他页面时,ApplicationBar 无法正常工作,因此问题不在 AppBar 内的按钮上。
I am developing simple app on Windows 8.
I have two UserControls: Locations and LocationsMap.
I am trying to navigate between them. For that I have added to static methods into App. They are like this
public static void ShowLocationsMap()
{
var page = new LocationsMap();
Window.Current.Content = page;
}
Navigation works fine.
But there is a problem. I am calling this method from button in ApplicationBar. XAML looks like this
<ApplicationBar x:Name="BottomAppBar" Height="88" VerticalAlignment="Bottom" Style="{StaticResource AppBarStyle}" Grid.Row="1">
<StackPanel Orientation="Horizontal">
<!-- Margin="left,top,right,bottom" -->
<StackPanel Orientation="Vertical" Margin="5,14,5,14">
<Button Content="Map" Click="MapButton_Click"></Button>
</StackPanel>
</StackPanel>
</ApplicationBar>
And I am navigating back by calling other function from next page.
The problem is that when I navigates back, ApplicationBar stopping to work. It is not showing after right click. If I set BottomAppBar.IsOpen to true, it shows up, but didn't closing.
Where is the problem?
P.S.
ApplicationBar is not working as well in case when I am navigating to other page from button on controls XAML, so problem is not on button inside AppBar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于导航,我使用从互联网下载的示例代码。该代码使用 App 类中定义的静态函数,这些函数正在更改 Window.Current.Content。
那是个坏主意。相反,如果我只需要使用 框架导航.
使用它时,我们需要将控件的类型从 UserControl 更改为 Page 。
应用程序栏现在可以很好地与导航配合使用。
希望这会对某人有所帮助。
For navigation I was using sample code downloaded from internet. That code was using static functions defined in App class, which were changing Window.Current.Content.
That was bad idea. Instead if that I just need to use Frame navigation.
When using it we need to change type of our controls from UserControl to Page.
Application bar works great with navigation now.
Hope this will help someone.