This is a migrated thread and some comments may be shown as answers.

UpdateSourceTrigger=LostFocus doesn't work with arrows

5 Answers 228 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Jiří
Top achievements
Rank 1
Jiří asked on 04 Aug 2017, 03:20 PM

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

Sort by
0
Stefan
Telerik team
answered on 09 Aug 2017, 10:46 AM
Hello Jiří,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Jiří
Top achievements
Rank 1
answered on 15 Aug 2017, 07:54 AM

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ří

0
Stefan
Telerik team
answered on 18 Aug 2017, 07:27 AM
Hi 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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Surendher
Top achievements
Rank 1
answered on 21 May 2018, 07:09 AM
Hello,

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>

0
Stefan
Telerik team
answered on 23 May 2018, 03:53 PM
Hello Surendher,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
NumericUpDown
Asked by
Jiří
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Jiří
Top achievements
Rank 1
Surendher
Top achievements
Rank 1
Share this question
or