2012-12-21 60 views
1

我有一個包含listbox的頁面,其中包含圖像。ApplicationBar出現在image_tap後

  <ListBox Name="photoListbox" ItemsSource="{Binding Photo}" > 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <Image Source="{Binding xBig}" Stretch="UniformToFill" Tap="ImageTap" /> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 

另外,我有一個應用程序欄在我的頁面上,當用戶不點擊圖像時它是不可見的。

<phone:PhoneApplicationPage.ApplicationBar> 
    <shell:ApplicationBar x:Name="AppBar" IsVisible="False"> 
     <shell:ApplicationBarIconButton x:Name="prevAppBarButton" 
             IconUri="Images/appbar.transport.rew.rest.png" 
             Text="previous" 
             IsEnabled="False" 
             /> 

     <shell:ApplicationBarIconButton x:Name="playAppBarButton" 
             IconUri="Images/appbar.transport.play.rest.png" 
             Text="play" 
             /> 

     <shell:ApplicationBarIconButton x:Name="pauseAppBarButton" 
             IconUri="Images/appbar.transport.pause.rest.png" 
             Text="pause" 
             IsEnabled="False" 
             /> 

     <shell:ApplicationBarIconButton x:Name="nextAppBarButton" 
             IconUri="Images/appbar.transport.ff.rest.png" 
             Text="next" 
             IsEnabled="False" 
             /> 
    </shell:ApplicationBar> 
</phone:PhoneApplicationPage.ApplicationBar> 

Image_Tap處理

private void ImageTap(object sender, GestureEventArgs e) 
    { 
     AppBar.IsVisible = true; 
    } 

但是,後來我拍打至圖像(我希望比我的外殼:應用程序任務欄會出現) - 我有一個NullReferenceException。我該怎麼辦?

回答

0

訪問工具欄使用頁面的ApplicationBar屬性:

private void ImageTap(object sender, GestureEventArgs e) 
{ 
    this.ApplicationBar.IsVisible = true; 
}