I am trying to register a user on my application using web API on Xamarin. Here is registration form in RegisterPage.xaml
<Entry Text="{Binding FirstName}" Placeholder="First Name"/>
<Entry Text="{Binding LastName}" Placeholder="Last Name"/>
<Entry Text="{Binding UserName}" Placeholder="Username"/>
<Entry Text="{Binding Email}" Placeholder="Email" />
<Entry Text="{Binding Password}" Placeholder="Password" IsPassword="True"/>
<Entry Text="{Binding ConfirmPassword}" Placeholder="Confirm Password" IsPassword="True"/>
<DatePicker x:Name="BirthDay" MinimumDate="1/1/1948" MaximumDate="12/31/2007"/>
<Label Text="Gender"/>
<Picker x:Name="GenderPicker" SelectedIndexChanged="GenderPicker_OnSelectedIndexChanged"/>
<Label Text="User Role"/>
<Picker x:Name="RolePicker" SelectedIndexChanged="RolePicker_OnSelectedIndexChanged"/>
<Button Command="{Binding RegisterCommand}" Text="Register"/>
<Label Text="{Binding Message}" />
Here is my RegisterPage.xaml.cs file
public partial class RegisterPage : ContentPage
{
public RegisterPage()
{
InitializeComponent();
GenderPicker.Items.Add("Male");
GenderPicker.Items.Add("Female");
RolePicker.Items.Add("Admin");
RolePicker.Items.Add("Participant");
}
private void GenderPicker_OnSelectedIndexChanged(object sender, EventArgs e)
{
var gender = GenderPicker.Items[GenderPicker.SelectedIndex];
}
private void RolePicker_OnSelectedIndexChanged(object sender, EventArgs e)
{
var role = RolePicker.Items[RolePicker.SelectedIndex];
}
}
On submitting the registration form I am not receiving my values against DatePiker and Picker into the RegisterCommand
Here is my RegisterCommand , I am receiving other attributes but not from DatePiker and Picker
public ICommand RegisterCommand
{
get
{
return new Command(async () =>
{
var isSuccess = await _apiServices.RegisterAsync(FirstName,LastName,UserName,Email,Password,ConfirmPassword,BirthDate,Gender,UserRole);
Message = isSuccess ? "Registered Successfully" : "Retry Later";
});
}
}