We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I want to change the color of error messages.

Thread ID:

Created:

Updated:

Platform:

Replies:

142247 Jan 24,2019 07:15 AM UTC Jan 25,2019 05:58 AM UTC Xamarin.Forms 1
loading
Tags: SfDataForm
Akhilesh
Asked On January 24, 2019 07:15 AM UTC

My background color is the same as errormessage so I want to change that one. Please help as soon as possible.
Thanks in advance.

Jayaleshwari N [Syncfusion]
Replied On January 25, 2019 05:58 AM UTC

  
Thanks for contacting Syncfusion Support.  
  
We have checked the reported query “Change Error Color ” from our side. You can customize the valid and invalid message in Validation view by using ValidationTemplate of SfDataForm, you can use custom view with desired color for valid and invalid message in Validation view.  
   
Code snippet XAML:  Validation template defined and bound to ValidationTemplate property   
  
<ContentPage.Resources>   
        <ResourceDictionary>   
            <local:TemplateSelector x:Key="validationDataTemplateSelector" />   
        </ResourceDictionary>   
    </ContentPage.Resources>           
<dataForm:SfDataForm Grid.Row="1" x:Name="dataForm" ValidationTemplate="{StaticResourcevalidationDataTemplateSelector}"  />   
   
Code snippet C#: ValidationTemplateSelector definition.  
  
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)   
{   
                var dataFormItem = item as DataFormItem;   
                if (dataFormItem.LabelText == "First Name")   
                {   
                    if (!dataFormItem.IsValid)   
                    {   
                        return InValidMessageTemplate;   
                    }   
                    else   
                    {   
                        return ValidMessageTemplate;   
                    }   
                }   
   
                else if (dataFormItem.LabelText == "Last Name")   
                {   
                    if (!dataFormItem.IsValid)   
                    {   
                        return LastNameTemplate;   
                    }   
                }   
   
                else if (dataFormItem.LabelText == "Email")   
                {   
                    if (!dataFormItem.IsValid)   
                    {   
                        return EmailTemplate;   
                    }   
                }   
                else if (dataFormItem.LabelText == "Contact Number")   
                {   
                    if (!dataFormItem.IsValid)   
                    {   
                        return ContactNumberTemplate;   
                    }   
                }   
                return null;               
}   
   
We have attached the sample for your reference and you can download the same from the following location.  
Sample link: DataForm_Validation   
   
Note: We have included this ValidationTemplate support in our 2018 Vol 4 main release (v16.4.0.44), please update to our latest version.    
  
Please let us know if you would require further assistance.  
   
Regards,   
Jayaleshwari N.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;