Hello,
I have a problem. I try to set a value inside the NumericUpDown (by writing/using up/down keys/clicking up/down arrows) that would change the source variable after focus lost. In case of writing a value (e.g. 234) and in case of pushing the up/down key I'm successful.
But when I try to do the same thing by clicking up/down arrow, change of source variable happens immediately.
<telerik:RadNumericUpDown Grid.Column=
"2"
Grid.Row=
"0"
Minimum=
"1"
Maximum=
"36000"
SmallChange=
"1"
LargeChange=
"1"
CustomUnit=
"s"
IsInteger=
"True"
Value=
"{Binding Settings.AnnotationSavingTimeout, UpdateSourceTrigger=LostFocus, Mode=TwoWay, Converter={StaticResource MillisecondsToSecondsConverter}}"
/>
Thank you for your help while finding the solution.
Jiří
5 Answers, 1 is accepted
Thank you for the code snippet provided.
In order to alter this default behavior, you can utilize the following workaround. When the LostFocus event is raised, you can handle the event by using a check as shown below.
private
void
RadNumericUpDown_LostFocus(
object
sender, RoutedEventArgs e)
{
var numeric = sender
as
RadNumericUpDown;
if
(numeric.IsKeyboardFocusWithin)
{
e.Handled =
true
;
}
}
I hope this helps.
Best Regards,
Stefan X1
Progress Telerik
Hello Stefan,
thank you for the workaround provided, it works.
But I'm surprised that there is no straightforward way how to achieve this behavior without need to work with code behind, because I think it should be feasible to do that by setting some property of NumericUpDown...
I think there is a platform, where I can write the same code of NumericUpDown and it really works as expected, so I wonder why it does not work in WPF...
Jiří
By the time being, we haven't received demand for implementing this option. We will have your feedback in mind in case there is such in the future. Meanwhile, you can stick to the approach presented in this thread.
All the best,
Stefan X1
Progress Telerik
I have used the RadNumericUpDown control inside GridViewDataColumn.CellEditTemplate.
What I need is when I click the up or down arrow the source property should not change, for that I kept "UpdateSourceTrigger=LostFocus" but it did not worked.
Below is the code,
<telerik:GridViewDataColumn x:Name="Quantity"
DataMemberBinding="{Binding Quantity}"
Header="{Quantity}"
ShowColumnWhenGrouped="False"
Width="*">
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<telerik:RadNumericUpDown Value="{Binding Quantity, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}"
UpdateValueEvent="LostFocus"
SmallChange="1"
NumberDecimalDigits="0"
Minimum="1">
</telerik:RadNumericUpDown>
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
Thanks for the code snippet.
Based on it, however, it is not clear to me whether you are using the workaround provided in one of my previous posts or not. Can you please clarify?
Thanks in advance for your cooperation.
Regards,
Stefan
Progress Telerik