سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top