What method / function is called during PivotItem WP7 navigation

I am just starting to develop Windows Phone 7 and lingering on this issue when using Pivot control:

I have 3 pivot names, and moving a swipe to move between centers works fabulously well, but the problem is ...

I need to call another function, for example function1 (), when one of them is displayed, and then call say function2 () as soon as the user moves to another pivotimeter.

Is there any delegate method that handles this.?

Thanks for your help!

+6
source share
2 answers

You can handle the Pivot control LoadingPivotItem . This event PivotItemEventArgs , which includes a property that lets you know which point will be shown. Using this, you can load the appropriate controls and properties. For instance,

 private void pivotMain_LoadingPivotItem(object sender, PivotItemEventArgs e) { if (e.Item == pivotItem1) { //Load Pivot Item 1 stuff } if (e.Item == pivotItem2) { //Load Pivot Item 2 stuff } } 

In the above example, pivotItem1 and pivotItem2 are the names I gave to each PivotItem so that you can specify any names you want for each PivotItem and see if they will be displayed. If you want to handle the event after loading PivotItem, you can use the Pivot.LoadedPivotItem method.

If you want to know which PivotItem is currently displayed at any time, you can use the Pivot.SelectedIndex method. It is based on zero, so the first PivotItem will have index 0 , the second will have 1 , etc.

+11
source

You can use SelectionChanged. In this function, you can check which PivotItem is the SelectedItem and choose which function you want to call.

+1
source

Source: https://habr.com/ru/post/890597/


All Articles