Mako
Mako

Reputation: 1515

Refresh Data of Windows Phone Panorama Item

I am developing a Windows Phone 8 application using the Panorama Page. I have around 5-6 Panorama items in my page which the user can scroll.

Currently i am binding the data of those pages when the Panorama page is loaded. Some of my Panorama items fetch data from the web service. For those pages, i want to fetch data only when the user scrolls to that item .

How can i achieve that ??

Upvotes: 1

Views: 356

Answers (1)

lsuarez
lsuarez

Reputation: 4992

Add a handler for your Panorama's SelectionChanged event and inspect the Panorama's SelectedIndex or SelectedItem properties to determine if the desired PanoramaItem is selected.

XAML

<phone:Panorama x:Name="myPanorama" Title="my application" SelectionChanged="Panorama_SelectionChanged">

    <!--Panorama item one-->
    <phone:PanoramaItem Header="item1">
        <Grid/>
    </phone:PanoramaItem>

    <!--Panorama item two-->
    <phone:PanoramaItem Header="item2">
        <Grid/>
    </phone:PanoramaItem>
</phone:Panorama>

Code Behind

private void Panorama_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (myPanorama.SelectedIndex == 2)
    {
        // Take on-demand actions
    }
}

Upvotes: 1

Related Questions