New to Telerik UI for WPF? Start a free 30-day trial
Pasting Value With Spaces in Front and Back Does Not Work
Updated on Sep 24, 2025
Environment
| Product Version | 2020.3.1020 |
| Product | RadNumericUpDown for WPF |
Description
Pasting a copied numeric value that contains untrimmed text does not work. In this case nothing happens.
Solution
Subscribe the RadNumericUpDown control to the DataObject's Pastring event and implement the pasting manually.
C#
DataObject.AddPastingHandler(this.numericUpDown, OnNumericUpDownPaste);
C#
private void OnNumericUpDownPaste(object sender, DataObjectPastingEventArgs e)
{
var copiedString = e.DataObject.GetData(typeof(string)) as string;
if (copiedString != null)
{
copiedString = copiedString.Trim();
double number = 0;
var success = double.TryParse(copiedString, out number);
if (success)
{
this.numericUpDown.SetCurrentValue(RadNumericUpDown.ValueProperty, number);
e.CancelCommand();
}
}
}