-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainPage.xaml.cs
45 lines (39 loc) · 1.31 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace PivotContentDemo
{
using System;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
this.InitializeComponent();
}
private void OnLoadingPivotItem(object sender, PivotItemEventArgs e)
{
// Do not set the content of the pivot item if the content has already been set
if (e.Item.Content != null)
{
return;
}
// Create the user control for the selected pivot item
var pivotItemContentControl = CreateUserControlForPivotItem(((Pivot)sender).SelectedIndex);
// Update the content of the pivot item
e.Item.Content = pivotItemContentControl;
}
private static UserControl CreateUserControlForPivotItem(int selectedIndex)
{
switch (selectedIndex)
{
case 0:
return new PivotItem1Content();
case 1:
return new PivotItem2Content();
case 2:
return new PivotItem3Content();
default:
throw new ArgumentOutOfRangeException("selectedIndex");
}
}
}
}