Hi Mohamed FKI,
Greetings from Syncfusion.
We have validated your query and prepared a sample based on your requirement. Please find the sample from the link below.
Here, validating the provided URI and return null to the ImageSource of AvatarView. After that ensure and update the desired text to it as per in below code snippet
Code Snippet[C#]: URL validation
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(value.ToString());
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response != null && response.StatusCode == HttpStatusCode.OK)
{
return value.ToString();
}
else
{
return null;
}
}
catch (Exception exception)
{
return null;
}
} |
In this sample, we have set the valid URL to display the Image for AvatarView. If you change invalid URL its Avatar view display characters.
Code Snippet [C#] : Change AvatarType
private void ChangeType()
{
if (avatar.ImageSource == null)
{
avatar.ContentType = ContentType.Initials;
avatar.AvatarName = "Alex";
avatar.InitialsType = InitialsType.SingleCharacter;
avatar.InitialsColor = Color.Black;
avatar.BackgroundColor = Color.Bisque;
}
} |
Please let us know if you have any concerns,
Regards,
Hemalatha M.