Disable RadDatePicker and RadTimePicker Default Validation in WPF

4 posts, 0 answers
  1. Martin
    Martin avatar
    1 posts
    Member since:
    Jun 2010

    Posted 13 Jul 2011 Link to this post


    I'm using xaml, view model and validation rule in C#

    The RadDatePicker has default validation for any invalid date. 

    In my xaml, I have my own validation rule for RadDatePicker and RadTimePicker with this Style of my ControlTemplate to display the error. (please see the xaml code below the for the Control Template Style and my validation rule)

    We allow the user to put nothing or empty string in the DatePicker unless we set it to mandatory that will use our validation rule to output a customized error style and message.In our validation rule, if we want to raise the error, it will use this code "return new ValidationResult(false, ErrorMessage);" However, since the default validation of RadDatePicker or RadTimePicker, it still set show the default error even the validation rule switches off the validation with this line  "return new ValidationResult(true, null);"

     Is there way I can disable the default behaviour and implement the custom behaviour I have?



    ====  Style of my ControlTemplate ==========

    <ControlTemplate x:Key="validationTemplate">
                        <TextBlock Foreground="Red" FontSize="20">!</TextBlock>
                <Style x:Key="radDatePicker" TargetType="{x:Type telerik:RadDatePicker}">
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="ToolTip"
                  Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                <Style x:Key="radTimePicker" TargetType="{x:Type telerik:RadTimePicker}">
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="ToolTip"
                  Value="{Binding RelativeSource={x:Static RelativeSource.Self},

    ==== xaml code to my validation rule ==========

                            <Binding Path="CommercialStartDateSelectedDate"
                                                FieldName="CommercialStartDate" InstanceId="{common:DataResourceBinding DataResource={StaticResource commercialLayoutDesignInstanceId}}" IsMandatory="{common:DataResourceBinding DataResource={StaticResource commercialStartDateIsMandatory}}" ErrorMessage="{x:Static local:Globalization.CommercialStartDateMandatoryErrorMessage}" >

                                                IsRecommended="{common:DataResourceBinding DataResource={StaticResource commercialStartDateIsRecommended}}" ErrorMessage="{x:Static local:Globalization.CommercialStartDateRecommendedErrorMessage}" >

  2. Pana
    Pana avatar
    748 posts

    Posted 15 Jul 2011 Link to this post

    Hello Martin,

    I am not sure I understand you well but from your description it sounds like you need to set the:


    On the RadDateTimePicker so the default red border does not appear.

    Kind regards,

    the Telerik team


    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Deloris
    Deloris avatar
    2 posts
    Member since:
    Jan 2015

    Posted 05 Jan 2015 Link to this post

    I need to be able to turn the validation process off in the DateTimePicker control.

    I have a similar issue. We have functionality in our application that allows the user to enter "t" or "h" in the date time picker to indicate the desire to use the current date or time. We have created a custom validation class that works well for this with the telerik control. However, we also allow our users to create macros that record groups of control with predetermined data entry information. Prior to switching to the Telerik control, if "t", for example was entered into the date time pick in a macro recording session, the "t" would remain in that space. The result is that when that macro was run, the "t" would be converted to the current date and time. Inherently, the Telerik control does validations that will, for example, convert the "Tuesday" into the next available date for Tuesday. In our case, because the "t" has a custom validation associated with it, it automatically convert to the current date. If I remove our custom validation, it returns an error because the Telerik validation system does not understand "t". I need to be able to turn this validation process off if it is determined that the user is currently recording a macro. I need to the field to allow the "t" to just exist.
  4. Kalin
    Kalin avatar
    1279 posts

    Posted 08 Jan 2015 Link to this post

    Hello Deloris,

    By Default Validation do you mean the parsing validation? You won't be able to remove, but you can change the parsing logic by implementing a custom parsing as demonstrated in the following article:

    However you won't be able to keep the entered input if the control loses the focus - it will parse the input somehow at that moment.

    Hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top