1
votes

I need to use Pivot but without loading all pages in all PivotItems. Need to Load/Relaod each page in PivotItem only when I pick this specific PivotItem.

I have tried, one bye one, all functionality which the Xaml provides, to make action only when the PivotItem is pressed but non suceeded.

<Pivot x:Name="XmlConfigPivot">
            <PivotItem Header="Layout">
                <Frame>
                    <xml_config:Layout_Tab/>
                </Frame>
            </PivotItem>
            <PivotItem Header="stub_tab">
                <Frame>
                    <xml_config:Stub_Tab/>
                </Frame>
            </PivotItem>
</Pivot>

How to make "xml_config:Layout_Tab" load only when I pick it's PivotItem?

1
Same problem here, it seems to be the "Default" behavior of the Pivot Control. I didn't try but, perhaps, if you add them programmatically instead of in the XAML you could choose when load them.Bruno

1 Answers

2
votes

As @Bruno said, you could directly load each page by programming. You just need to register the SelectionChanged event for the Pivot and add some code logic to achieve it.

The following is a simple code sample for your reference:

<Pivot x:Name="XmlConfigPivot" SelectionChanged="XmlConfigPivot_SelectionChanged">
        <PivotItem Header="Layout">
            <Frame>
            </Frame>
        </PivotItem>
        <PivotItem Header="stub_tab">
            <Frame>
            </Frame>
        </PivotItem>
</Pivot>
private void XmlConfigPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    PivotItem item = ((sender as Pivot).SelectedItem) as PivotItem;
    string header = item.Header.ToString();
    Frame frame = item.Content as Frame;
    switch (header)
    {
            case "Layout": frame?.Navigate(typeof(page1)); break;
            case "stub_tab": frame?.Navigate(typeof(page2)); break;
    }
}