[英]WP8 update pivot title from other class
I just can't figure out how to fix this... I'd like to update MainPage pivot title from other class. 我只是无法弄清楚如何解决这个问题...我想从其他类更新MainPage数据透视标题。 I have method in MainPage that does it and it obviously works fine when doing the update inside MainPage but obviously it doesn't do anything when I call the MainPage method from the other class.
我在MainPage中有方法,它在MainPage中进行更新时显然工作正常,但是当我从另一个类调用MainPage方法时它显然没有做任何事情。
So basically the situation is this for the class: 所以基本上情况是这个类:
MainPage mp = new MainPage();
mp.UpdateTitle();
and the MainPage: 和MainPage:
public void UpdateTitle()
{
Pivotname.Title = App.somevalue;
}
That obviously doesn't work. 这显然不起作用。 What would be the best solution for updating page's pivot title from any class?
什么是从任何类更新页面的数据透视标题的最佳解决方案? I'm really new to WP8 development and I just can't seem to figure out solution for this.
我是WP8开发的新手,我似乎无法找到解决方案。
You can try with static reference of MainPage
and use it in another class. 您可以尝试使用
MainPage
静态引用,并在另一个类中使用它。
public static MainPage CurrentMainPage;
public MainPage()
{
InitializeComponent();
CurrentMainPage = this;
}
From another class 来自另一个班级
MainPage.CurrentMainPage.UpdateTitle();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.