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. Image for the cookie policy date

I want to change the color of error messages.

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

1 Reply

JN Jayaleshwari N Syncfusion Team 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.  


Loader.
Live Chat Icon For mobile
Up arrow icon