C# 数据透视项';头球总是先说
每当我调试应用程序时,不管我对数据透视项的标题做了什么,它都会说“第一”,而数据透视的标题总是说“我的应用程序” 代码: PivotPage.xaml:C# 数据透视项';头球总是先说,c#,xaml,windows-phone-8.1,C#,Xaml,Windows Phone 8.1,每当我调试应用程序时,不管我对数据透视项的标题做了什么,它都会说“第一”,而数据透视的标题总是说“我的应用程序” 代码: PivotPage.xaml: <Pivot x:Uid="Pivot" Title="THE BOX" x:Name="pivot"> <!--Pivot item one--> <PivotItem x:Uid="PivotItem1" Header="The Box" Margin="19,
<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>
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.cs:
<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>
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();
}
}
公共密封部分类数据透视页:第页,INotifyPropertyChanged
{
私有只读NavigationHelper NavigationHelper;
私有只读资源加载器资源加载器=
ResourceLoader.GetForCurrentView(“资源”);
公共事件属性更改事件处理程序属性更改;
公共数据透视页()
{
this.InitializeComponent();
DataContext=this;
this.NavigationCacheMode=NavigationCacheMode.Required;
this.navigationHelper=新的navigationHelper(this);
this.navigationHelper.LoadState+=this.navigationHelper\u LoadState;
this.navigationHelper.SaveState+=this.navigationHelper\u SaveState;
}
///
///获取与此关联的。
///
公共导航帮助器导航帮助器
{
获取{返回this.navigationHelper;}
}
私有异步void NavigationHelper\u LoadState(对象发送方,LoadStateEventArgs e)
{
}
私有void NavigationHelper_SaveState(对象发送方,SaveStateEventArgs e)
{
//TODO:在此处保存页面的唯一状态。
}
///
///单击应用程序栏按钮时将项目添加到列表中。
///
私有void AddAppBarButton_单击(对象发送者,路由目标e)
{
Box=Note.MakeTable();
}
私有void OnPropertyChanged(字符串属性\u名称)
{
if(PropertyChanged!=null)
{
PropertyChanged(这是新PropertyChangedEventArgs(property_name));
}
}
#区域导航助手注册
受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
受保护的覆盖无效OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#端区
私有void生成表(对象发送方,TappedRoutedEventArgs e)
{
Box=Note.MakeTable();
}
私有无效按钮\u单击(对象发送者,路由目标e)
{
Box=Note.MakeTable();
}
}
屏幕截图:
<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>
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中更改了启动?我会再检查一次,但我很确定没有任何与此相关的东西,这就是代码背后。@depchie:no。没什么。而且不再有主页了。xaml?@depchie:不,这不是WPF;这是Windows-Phone。是的,如果使用了资源,也可能是这样:)@Roman:如果我在这里声明,为什么会这样?或者更好的是,x:Uid对Resources.resw做了什么?没关系。单击链接。那就对了。谢谢数据透视页模板通过在新项目启动时添加所有这些额外内容来发挥作用。