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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the validation error template color?

Platform: WPF |
Control: SfDataGrid |
Published Date: September 2, 2014 |
Last Revised Date: March 28, 2017 |
.NET Framework: 4.5

The SfDataGrid provides a convenient way to validate data and indicate the errors along with its information. By default, validation error templates are displayed in red. However, the SfDataGrid allows you to customize the Validation error template or its icon by writing style for GridCell and GridRowHeaderCell. You can change the validation error template color of the cell by editing the ControlTemplate of the GridCell and also setting the error path fill color. For example, yellow. You can change the validation error template color of the RowHeader by editing the ControlTemplate of the GridRowHeaderCell and setting the path fill color as any. For example, yellow.


The control template of the GridRowHeaderCell contains two VisualStateGroups; BorderStates that specifies the BorderThickness of the GridRowHeaderCell and IndicationStates that contains the visual states, CurrentRowError, Error, CurrentRow, Editing row and AddNewRow. The validation error template color of the GridRowHeaderCell is changed by editing the visual state Error. It contains two classes, ObjectAnimationUsingKeyFrames where the error template is drawn and ColorAnimationUsingKeyFrames where the color of the error template is mentioned. The validation error template color is changed by changing the value property of the EasingColorKeyFrame.



The control template of the GridCell contains only one VisualStateGroup that contains the visual states HasError and NoError. The HasError state specifies the width of the error template of the cell and NoError state depicts the state of the cell when it has no errors. Apart from the VisualStateGroup, the control template of the GridCell has three borders. A ContentPresenter is loaded in the first border where the contents of the cell are displayed. The Second border is the CurrentCellBorder and the third border displays the error template. You can change the validation error template color of the GridCell by changing the Fill property of the path codes in the third border.



The following screenshot displays the output for the above code in the SfDataGrid.

D:\Syncfusion\Issues\2014 Volume 2\KB Issues\KB Images\ValidationErrorTemplate.png

Note: The above code examples are for WPF. For WinRT and Silverlight platforms, refer to the following samples.

Sample Links

WPF: DataValidationDemo_WPF

WRT: DataValidationDemo_WRT.zip

SilverLight: DataValidationDemo_SL.zip

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile