I have a page with only a bar. This page is always cached . Now, when I go to this page, I want its contents and selection to be loaded from the cache, but I want to have the first PivotItemin the view. XAML:
<Pivot x:Name="FilterPivot"
IsHeaderItemsCarouselEnabled="True"
SelectedIndex="0">
<PivotItem Header="Author" >
<ListBox ItemsSource="{x:Bind AuthorFacets, Mode=OneWay}"
Name="AuthorListBox"
SelectionMode="Multiple"
SelectionChanged="AuthorListBox_SelectionChanged">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate x:DataType="local:IFacet">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{x:Bind read}"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Center"/>
<Border Grid.Column="1"
Background="Gray"
MinWidth="25"
CornerRadius="8">
<TextBlock Text="{x:Bind num}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="2"/>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</PivotItem>
<PivotItem Header="Language">
....
....
</PivotItem>
<PivotItem Header="Learning Resource Type">
....
....
</PivotItem>
<PivotItem Header="Subject">
....
....
</PivotItem>
<PivotItem Header="Type">
....
....
</PivotItem>
<PivotItem Header="Education Level">
....
....
</PivotItem>
<PivotItem Header="Source">
....
....
</PivotItem>
</Pivot>
This is my code:
public FilterPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
FilterPivot.SelectedIndex = 0;
}
Instead, instead of the 0th index, it displays the cached PivotItemone that was selected when the user switched from viewing.
source
share