Frage

I need to handle the event when the application bar is minimized or not, but my code apparently doesn't work.I add the StateChanged event but it doesn't work.

  <phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar x:Name="option_bar" Mode="Minimized" Opacity="0.9"  StateChanged="ApplicationBar_StateChanged">
        <shell:ApplicationBarIconButton IconUri="/Images/coupons.png" Text="Kupony"  />
        <shell:ApplicationBarIconButton IconUri="/Images/basket.png" Text="Koszyk" Click="GoToBasket_Click" ></shell:ApplicationBarIconButton>
        <shell:ApplicationBarIconButton IconUri="/Images/myaccount.png" Text="Moje Konto" Click="Update_Click" />
        <shell:ApplicationBarIconButton IconUri="/Images/road.png" Text="Wyloguj się" Click="logout_Click" />
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

this is my code in c# which should be invoked when the state of application bar is change d by user:

private void ApplicationBar_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
        {
            if (option_bar.Mode == ApplicationBarMode.Minimized) 
            {
                MessageBox.Show("fjfsdfds");
            }
            if (e.IsMenuVisible  == true)
            {
                MessageBox.Show("second");
            }
            if (option_bar.IsVisible)
            {
                MessageBox.Show("third");
            }
        }

I think, that even the ApplicationBar_StateChanged isn't invoked.

War es hilfreich?

Lösung

The ApplicationBar.StateChanged is invoked only when you have MenuItems in ApplicationBar. Try to add a MenuItem and check if the event was invoked.

Similar problem was answered here at MSDN forum.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top