UpdateSourceTrigger=LostFocus doesn't work with arrows

4 posts, 0 answers
  1. Jiří
    Jiří avatar
    2 posts
    Member since:
    Aug 2017

    Posted 04 Aug Link to this post

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

  2. Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 09 Aug Link to this post

    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.
  3. Jiří
    Jiří avatar
    2 posts
    Member since:
    Aug 2017

    Posted 15 Aug Link to this post

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

  4. Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 18 Aug Link to this post

    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.
Back to Top