2012-12-11 40 views
1

我正在嘗試使用Cirrious Conference示例創建選項卡式視圖,但似乎在顯示我的數據時出現問題。當它承載的標籤的視圖,具體在下面的代碼當在TabHost中添加選項卡時ViewModel數據丟失

// Initialize a TabSpec for each tab and add it to the TabHost spec = TabHost.NewTabSpec("welcome"); spec.SetIndicator(this.GetText("Welcome"),Resources.GetDrawable(Resource.Drawable.Tab_Welcome)); spec.SetContent(CreateIntentFor(ViewModel.Welcome)); TabHost.AddTab(spec);

我的視圖模型CALSS調用的問題出現低於

public class WelcomeViewModel : MvxViewModel 
{ 
    private string _description; 
    public string Description 
    { 
     get 
     { 
      return _description; 
     } 
     set 
     { 
      _description = value; 
      FirePropertyChanged("Description"); 
     } 
    } 

    public WelcomeViewModel(string description) 
    { 
     Description = description; 
    } 

    public WelcomeViewModel() 
    { 

    } 
} 

的ViewModel.Welcome對象被創建,並與數據初始化傳遞給它並保持如此狀態,直到控件通過SetContent方法,但是當調用AddTab時,WelcomeViewModel構造函數似乎再次被調用並且數據被重置。調用堆棧跟蹤此在BaseTabbedView類

base.OnCreate(bundle);

電話。如何保持WelcomeViewModel中的數據,以便它顯示在我的選項卡中,非常感謝

回答