Maverick
Maverick

Reputation: 2022

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. I have select application bar button, when i select it, i am enabling the LongListSelector.IsSelectionEnabled to true for my current LongList control. 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. 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?

Upvotes: 1

Views: 1424

Answers (2)

Rajmohan Kathiresan
Rajmohan Kathiresan

Reputation: 338

Set PivotControl.IsLocked to true in editing mode. User will be able to see / interact with the current default pivot item , turn it to false once done with editing .

Upvotes: 3

Depechie
Depechie

Reputation: 6142

Had the same issue... seems that Pivot visibility set to collapsed isn't enough to 'hide' them.

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

Upvotes: 0

Related Questions