在Windows Phone 8中选择其他数据透视表项时隐藏其他数据透视表项标题

时间:2013-11-07 14:07:13

标签: c# xaml windows-phone-8

我的Windows Phone 8应用程序中有三个透视项目。 我有选择应用程序栏按钮,当我选择它时,我为当前的LongList控件启用LongListSelector.IsSelectionEnabled为true。但我想隐藏其他枢轴项目,我试图使用visiblity属性,但它没有工作,似乎我正在尝试自定义标题。 我的透视项代码是`

        <!--Pivot item one-->
        <phone:PivotItem x:Name="allPivotItem">   
            <phone:PivotItem.Header>
                <TextBlock Text="{Binding Path=LocalizedResources.all, Source={StaticResource LocalizedStrings}}" Foreground="#FF81BD5E"></TextBlock>                  
            </phone:PivotItem.Header>
            <toolkit:LongListMultiSelector x:Name="allTaskLongList" 
                                           LayoutMode="List"
                                           ItemTemplate="{StaticResource MyTaskItemTemplate}"
                                           SelectionChanged="OnAllTaskSelectionChanged"
                                           IsSelectionEnabledChanged="OnAllTaskIsSelectionEnabledChanged"
                                           ItemInfoTemplate="{StaticResource MyTaskItemInfoTemplate}">                    
            </toolkit:LongListMultiSelector>             
        </phone:PivotItem>

        <phone:PivotItem>
            <phone:PivotItem.Header>
                <TextBlock Text="{Binding Path=LocalizedResources.assigned,Source={StaticResource LocalizedStrings}}" Foreground="#FF126EA2"></TextBlock>
            </phone:PivotItem.Header>
            <toolkit:LongListMultiSelector x:Name="assignedTaskLongList"
                                           LayoutMode="List"
                                           ItemTemplate="{StaticResource MyTaskItemTemplate}"
                                           SelectionChanged="OnAllTaskSelectionChanged"
                                           IsSelectionEnabledChanged="OnAllTaskIsSelectionEnabledChanged"
                                           ItemInfoTemplate="{StaticResource MyTaskItemInfoTemplate}">
            </toolkit:LongListMultiSelector>
        </phone:PivotItem>

        <phone:PivotItem>
            <phone:PivotItem.Header>
                <TextBlock Text="{Binding Path=LocalizedResources.overdue,Source={StaticResource LocalizedStrings}}"
                           Foreground="#FF825887"></TextBlock>
            </phone:PivotItem.Header>
            <toolkit:LongListMultiSelector x:Name="overdueTaskLongList"
                                           LayoutMode="List"
                                           ItemTemplate="{StaticResource MyTaskItemTemplate}"
                                           SelectionChanged="OnAllTaskSelectionChanged"
                                           IsSelectionEnabledChanged="OnAllTaskIsSelectionEnabledChanged"
                                           ItemInfoTemplate="{StaticResource MyTaskItemInfoTemplate}">                    
            </toolkit:LongListMultiSelector>
        </phone:PivotItem>
    </phone:Pivot>`

以及隐藏其他数据透视项的代码

void OnSelect_Click(object sender, EventArgs e)
    {
        allTaskLongList.IsSelectionEnabled = true;

       assignedTaskLongList.Visibility = System.Windows.Visibility.Collapsed;
    overdueTaskLongList.Visibility = System.Windows.Visibility.Collapsed;
    }

请建议我如何隐藏其他支点项目?

2 个答案:

答案 0 :(得分:3)

在编辑模式下将PivotControl.IsLocked设置为true。用户将能够看到/与当前默认枢轴项交互,一旦完成编辑就将其变为false。

答案 1 :(得分:0)

有同样的问题......似乎Pivot可见性设置为折叠不足以“隐藏”它们。

我提出的唯一解决方案是循环遍历枢轴项目并“删除”每个将其可见性设置为“折叠”的项目。

您可以在我的代码后面看到这一点:https://github.com/Depechie/GF13/blob/master/AppCreativity.GentseFeesten.WP8/AppCreativity.GentseFeesten.WP8/View/MainPage.xaml.cs&gt;方法ChangePivotItems

相关问题