我的页面中有一个带CommandParameter的Command,但是当PageModel的触发器值为null时,我就没有了。 我有一个模型“UserLogin”:
[AddINotifyPropertyChangedInterface]
public class UserLogin
{
public string Username { get; set; }
public string Password { get; set; }
public UserLogin(string username, string password)
{
Username = username;
Password = Password;
}
public UserLogin()
{
}
}
我的各个PageModel是“LoginPageModel”:
[AddINotifyPropertyChangedInterface]
public class LoginPageModel : FreshBasePageModel
{
IDatabaseService _databaseService;
IUserDialogs _userDialogs;
IRestService _restService;
public LoginPageModel(IDatabaseService databaseService, IRestService restService, IUserDialogs userDialogs) //injected from IOC
{
_databaseService = databaseService;
_restService = restService;
_userDialogs = userDialogs;
}
private UserLogin _userLogin;
public UserLogin UserLogin
{
get
{
return _userLogin;
}
set
{
_userLogin = value;
if (value != null)
RaisePropertyChanged();
}
}
public Command LoginCommand
{
get
{
return new Command<UserLogin>(async (log) =>
{
....
}
我的相应页面是“LoginPage.xaml”:
<ContentPage.Content>
<StackLayout Padding="20" Spacing="5">
<Entry x:Name="Username" Text="{Binding Username}" Keyboard="Email" Placeholder="Username" />
<Entry x:Name="Password" Text="{Binding Password}" Placeholder="Password" IsPassword="true" />
<Button x:Name="btn_Login" Command="{Binding LoginCommand}" CommandParameter="{Binding UserLogin}" Text="Login" />
</StackLayout>
</ContentPage.Content>
我的参数代码出错了吗?
谢谢人