Pasting Value With Spaces in Front and Back Does Not Work
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.
DataObject.AddPastingHandler(this.numericUpDown, OnNumericUpDownPaste);
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();
}
}
}