在Windows Phone 8中使用C#更改PanoramaItem的可见性

时间:2014-08-01 07:53:30

标签: c# windows-phone-8 windows-phone

我正在使用C#启用panoramaItem的可见性。默认情况下,panoramaItem设置为Collapsed。见下文:

<phone:PanoramaItem Header="select" Visibility="Collapsed" x:Name="SelectGroup">
            <TextBlock Text="HI" Margin="30" FontSize="36"></TextBlock>
</phone:PanoramaItem>

现在有一个TextBlock,我创建了一个Tap事件:

<TextBlock x:Name="SeachBloodGroup" Text="A+" FontSize="30" Tap="BloodGroup_Tap"></TextBlock>

代码:

private void BloodGroup_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    SelectGroup.Visibility = SelectGroup.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;           
}

但是panoramaItem没有显示。

1 个答案:

答案 0 :(得分:1)

试试这个:

private void BloodGroup_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    if (SelectGroup.Visibility == System.Windows.Visibility.Collapsed)
        SelectGroup.Visibility = System.Windows.Visibility.Visible;
    else
        SelectGroup.Visibility = System.Windows.Visibility.Collapsed;
}