ApplicationBar出现在image_tap之后

时间:2012-12-21 15:08:44

标签: c# silverlight windows-phone-7

我有一个包含列表框的页面,其中包含图像。

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

另外,我的页面上有一个ApplicationBar,当用户不点击图像时,它是不可见的。

<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;
    }

但是,然后我点击图像(我希望比我的shell:ApplicationBar会出现) - 我有一个nullReferenceException。我该怎么办?

1 个答案:

答案 0 :(得分:0)

使用页面的ApplicationBar属性访问工具栏:

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