Вопрос

How can I regulate an Opacity of ApplicationBar when it opens and when it closes in Windows Phone. There is onle ove event:

 <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar x:Name="AppBar_FeedPivotPage" Opacity="0.5" ForegroundColor="Black" BackgroundColor="White"  StateChanged="AppBar_FeedPivotPage_StateChanged">

private void GlobalAppBar_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
    {
        ApplicationBar appBar = (ApplicationBar)sender;
        var opacity = appBar.Opacity;
        if (opacity == 0.5)
        {

            appBar.Opacity == 1;
        }
        else
        {
            appBar.Opacity == 0.95;
        }
    }

But there is null reference exeption

Это было полезно?

Решение

Try using the sender argument as follows:

  private void AppBar_FeedPivotPage_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
  {
    ApplicationBar appBar = (ApplicationBar)sender;
    var opacity = appBar.Opacity;
  }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top