【问题标题】:Hide other pivot item header on selection of other pivot item in Windows Phone 8在 Windows Phone 8 中选择其他数据透视项目时隐藏其他数据透视项目标题
【发布时间】:2013-11-07 14:07:13
【问题描述】:

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

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

请建议我如何隐藏其他枢轴项目?

【问题讨论】:

    标签: c# xaml windows-phone-8


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-04-10
        • 1970-01-01
        • 1970-01-01
        • 2012-09-25
        • 1970-01-01
        • 2013-02-12
        • 1970-01-01
        • 2018-10-08
        相关资源
        最近更新 更多