Unplanned
Last Updated: 10 Nov 2025 09:29 by Stenly
Stenly
Created on: 10 Nov 2025 09:29
Category: DateRangePicker
Type: Bug Report
2
DateRangePicker: An exception is raised when pasting invalid input

Pasting an invalid range of dates in the RadDateRangePicker, for example, "ABC", raises an exception.

To work around this behavior, you could subscribe to the Loaded event of RadDateRangePicker and retrieve the DateRangeMaskedInput element via the visual tree helper methods. Then, subscribe to its ValueChanging event and check whether the NewValue property of the event arguments contains any letters or characters that are not valid. If it does, set the Handled property to True.

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        this.dateRangePicker.Loaded += DateRangePicker_Loaded;
    }

    private void DateRangePicker_Loaded(object sender, RoutedEventArgs e)
    {
        DateRangeMaskedInput dateRangeMaskedInput = this.dateRangePicker.FindChildByType<DateRangeMaskedInput>();

        if (dateRangeMaskedInput != null)
        {
            dateRangeMaskedInput.ValueChanging += DateRangeMaskedInput_ValueChanging;
        }
    }

    private void DateRangeMaskedInput_ValueChanging(object? sender, Telerik.Windows.Controls.MaskedInput.RadMaskedInputValueChangingEventArgs e)
    {
        if (e.NewValue.ToString().Any(char.IsLetter))
        {
            e.Handled = true;
        }
    }
}

0 comments