【发布时间】:2015-12-31 07:56:35
【问题描述】:
每当我调试应用程序时,无论我对 PivotItem 的标头做什么,它都会说“first”,而 Pivot 的 Title 总是说“MY APPLICATION”。
代码:
PivotPage.xaml:
<Pivot x:Uid="Pivot" Title="THE BOX" x:Name="pivot">
<!--Pivot item one-->
<PivotItem
x:Uid="PivotItem1" Header="The Box"
Margin="19,14.5,0,0" CommonNavigationTransitionInfo.IsStaggerElement="True">
</PivotItem>
</Pivot>
更新: 我在代码隐藏中没有发现任何影响这种行为的东西:
PivotPage.xaml.cs:
public sealed partial class PivotPage : Page, INotifyPropertyChanged
{
private readonly NavigationHelper navigationHelper;
private readonly ResourceLoader resourceLoader =
ResourceLoader.GetForCurrentView("Resources");
public event PropertyChangedEventHandler PropertyChanged;
public PivotPage()
{
this.InitializeComponent();
DataContext = this;
this.NavigationCacheMode = NavigationCacheMode.Required;
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
}
/// <summary>
/// Gets the <see cref="NavigationHelper"/> associated with this <see cref="Page"/>.
/// </summary>
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
}
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
// TODO: Save the unique state of the page here.
}
/// <summary>
/// Adds an item to the list when the app bar button is clicked.
/// </summary>
private void AddAppBarButton_Click(object sender, RoutedEventArgs e)
{
Box = Note.MakeTable();
}
private void OnPropertyChanged(string property_name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property_name));
}
}
#region NavigationHelper registration
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#endregion
private void MakeTable(object sender, TappedRoutedEventArgs e)
{
Box = Note.MakeTable();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Box = Note.MakeTable();
}
}
截图:
【问题讨论】:
-
这很奇怪! PivotPage.xaml 后面的代码中没有代码?确定加载的是那个页面,你删除了默认的 MainPage.xaml 并更改了 app.xaml.cs 中的启动?
-
我会再检查一次,但我很确定没有任何与此相关的内容是代码隐藏。
-
@Depechie:不。什么都没有。
-
而且不再有 MainPage.xaml?
-
@Depechie:不。这不是 WPF;这是 Windows 手机。
标签: c# xaml windows-phone-8.1