2013-10-25 57 views
0

我只是不知道如何解決這個問題...我想更新其他類的MainPage樞軸標題。我在MainPage中有這樣的方法,它在MainPage中執行更新時顯然工作正常,但顯然當我從另一個類調用MainPage方法時,它不會執行任何操作。WP8更新從其他類的樞軸標題

所以基本上情況是這樣的類:

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

和的MainPage:

public void UpdateTitle() 
{ 
    Pivotname.Title = App.somevalue; 
} 

這顯然是行不通的。什麼是從任何類更新頁面的樞軸標題的最佳解決方案?我對WP8開發非常陌生,我似乎無法找出解決方案。

回答

2

您可以嘗試使用靜態引用MainPage並在另一個類中使用它。

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

從另一個類

MainPage.CurrentMainPage.UpdateTitle(); 
+0

由於一噸!非常明顯......噢。 – Tup3x

+0

歡迎:) :) :) – Xyroid

+0

嗨xyroid,你能幫我在下面的問題 http://stackoverflow.com/questions/22216367/how-to-refresh-the-data-in-pivot-item-after-更新數據貫通用戶控件?noredirect = 1#comment33732020_22216367 –