如何在应用栏打开时以及在Windows Phone中关闭时调整应用栏的不透明度。有丰富的活动:
<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;
}
}
但是有nullreferenceexception
答案 0 :(得分:3)
尝试使用sender
参数,如下所示:
private void AppBar_FeedPivotPage_StateChanged(object sender, ApplicationBarStateChangedEventArgs e)
{
ApplicationBar appBar = (ApplicationBar)sender;
var opacity = appBar.Opacity;
}