0
我用QuickCross作爲MVVM框架爲我的項目:https://github.com/MacawNL/QuickCross 爲導向,我創建了一個命令Xamarin QuickCross如何使用異步命令
public RelayCommand RegisterCommand /* Data-bindable command that calls Register(), generated with cmd snippet. Keep on one line - see http://goo.gl/Yg6QMd for why. */ { get { if (_RegisterCommand == null) _RegisterCommand = new RelayCommand(Register); return _RegisterCommand; } } private RelayCommand _RegisterCommand; public const string COMMANDNAME_RegisterCommand = "RegisterCommand";
private void Register()
{
//TODO: Check valid model
var request = new RegistrationRequest
{
FullName = FullName,
UserEmail = Email,
Password = Password,
UserType = UserType
};
var response = userClientApi.Register(request);
if (response.Succeed)
{
//TODO: handle success data
}
}
我工作的偉大,但我創建了一個異步函數:RegisterAsync。如何在RelayCommand中調用異步方法如下:
var response = await userClientApi.RegisterAsync(request);
謝謝您的閱讀。
我工作過,謝謝! – 2014-10-17 09:56:15