简体   繁体   English

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

[英]Hide other pivot item header on selection of other pivot item in Windows Phone 8

I am having three pivot items in my windows phone 8 app. 我的Windows Phone 8应用程序中有三个透视项目。 I have select application bar button, when i select it, i am enabling the LongListSelector.IsSelectionEnabled to true for my current LongList control. 我有选择应用程序栏按钮,当我选择它时,我为当前的LongList控件启用LongListSelector.IsSelectionEnabled为true。 but i want to hide the other pivot items, i tried to use the visiblity property but it did not work, seems i am trying customized header. 但我想隐藏其他枢轴项目,我试图使用visiblity属性,但它没有工作,似乎我正在尝试自定义标题。 My code of pivot items is ` 我的枢轴项代码是`

        <!--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>`

and the code for hiding other pivot items 以及隐藏其他枢轴项的代码

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

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

Please suggest how can i hide the other pivot items? 请建议我如何隐藏其他枢轴物品?

Set PivotControl.IsLocked to true in editing mode. 在编辑模式下将PivotControl.IsLocked设置为true。 User will be able to see / interact with the current default pivot item , turn it to false once done with editing . 用户将能够查看/与当前默认枢轴项交互,一旦完成编辑就将其变为false。

Had the same issue... seems that Pivot visibility set to collapsed isn't enough to 'hide' them. 有同样的问题......似乎Pivot可见性设置为折叠不足以“隐藏”它们。

The only solution I came up with, was looping through the pivot items and 'remove' each one that has it's visibility set to Collapsed. 我提出的唯一解决方案是循环遍历枢轴项目并“删除”每个将其可见性设置为“折叠”的项目。

You can see this in my code behind here: https://github.com/Depechie/GF13/blob/master/AppCreativity.GentseFeesten.WP8/AppCreativity.GentseFeesten.WP8/View/MainPage.xaml.cs > method ChangePivotItems 您可以在我的代码后面看到这个: https//github.com/Depechie/GF13/blob/master/AppCreativity.GentseFeesten.WP8/AppCreativity.GentseFeesten.WP8/View/MainPage.xaml.cs > method ChangePivotItems

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM