问题
I have a Pivot Control in MainPage.xaml page. I add in the PageOne.xaml.cs as pivot item using
private void OnLoadingPivotItem(object sender, PivotItemEventArgs e)
{
if (e.Item.Content != null)
{
// Content loaded already
return;
}
Pivot pivot = (Pivot)sender;
if (e.Item == pivot.Items[0])
{
e.Item.Content = new PageOne();
}
}
Thing is not working so fine, but I have tried to fix them, for example,
// NavigationService.Navigation(new Uri());
// need to change to
(App.Current as App).RootFrame.Navigate( new Uri());
// ApplicationBar for PivotItem
appBar = ((PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content).ApplicationBar;
Now, I need to show ProgressIndicator on my PivotControl MainPage.xaml from my PageOne.xaml.cs code.
_progressIndicator = new ProgressIndicator
{
IsIndeterminate = true,
IsVisible = false,
};
SystemTray.SetProgressIndicator(this, _progressIndicator);
But progressIndicator doesn't show, what should I do? My guess is to call the SystemTray of RootFrame but I am not sure how to.
回答1:
Try change the property IsVisible
to true
.
Wish this can help you.
回答2:
I need to pass MainPage as reference to PageOne, and put it as parameter when using SystemTray.SetProgressIndicator.
In MainPage.xaml.cs
e.Item.Content = new PageOne(this);
Here is the constructor code from PageOne.xaml.cs
public PageOne(MainPage page) {
_progressIndicator = new ProgressIndicator
{
IsIndeterminate = true,
IsVisible = false,
};
SystemTray.SetProgressIndicator(page, _progressIndicator);
}
来源:https://stackoverflow.com/questions/22745852/systemtray-for-pivot-item-content