简体   繁体   中英

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. 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.

So basically the situation is this for the class:

MainPage mp = new MainPage();
mp.UpdateTitle();

and the 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.

You can try with static reference of MainPage and use it in another class.

public static MainPage CurrentMainPage;
public MainPage()
{
    InitializeComponent();
    CurrentMainPage = this;
}

From another class

MainPage.CurrentMainPage.UpdateTitle();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM