Hello,
You could use the Entry's TextChanged
event to implement this feature to alert the user if this username exists.
If you already have a method to verify usernames from FireBase, which is an asynchronous method called VerifyIfUserNameExists
, you could refer to the following code:
private async void userName_TextChanged(object sender, TextChangedEventArgs e)
{
if(e.NewTextValue != string.Empty) //Detection of presence begins when the user starts typing
{
if(await VerifyIfUserNameExists(e.NewTextValue))
{
AlertLabel.IsVisible = true; // Use a label to alert.
AlertLabel.Text = "This username has been existed!";
}else
{
AlertLabel.IsVisible = false;
AlertLabel.Text = "";
}
}else
{
AlertLabel.IsVisible = false;
AlertLabel.Text = "";
}
}
<Entry x:Name="userName" TextChanged="userName_TextChanged"/>
<Label x:Name="AlertLabel" IsVisible="false" TextColor="Red"/>
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.