我正在玩mvvmcross5导航服务。 我尝试从Initialize方法更改标签,但没有任何反应。
我做错了什么?
这是一个简单的代码:
public class SecondViewModel : MvxViewModel<Dictionary<string, string>>
{
private readonly IMvxNavigationService _navigationService;
private string _mainPageButtonText = "test";
public SecondViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;
}
public string MainPageButtonText
{
get
{
return _mainPageButtonText;
}
set
{
SetProperty(ref _mainPageButtonText, value);
}
}
public IMvxAsyncCommand BackCommand => new MvxAsyncCommand(() => {
MainPageButtonText = "it works";
return Task.FromResult(true);
});
public override Task Initialize(Dictionary<string, string> parameter)
{
MainPageButtonText = "it does not work";
return Task.FromResult(true);
}
}
答案 0 :(得分:0)
这是MvvmCross中的一个错误,将在5.0.2中修复。见https://github.com/MvvmCross/MvvmCross/releases/tag/5.0.2