ValueChanged event doesn't fire as they are typing

7 posts, 0 answers
  1. gunther
    gunther avatar
    95 posts
    Member since:
    Mar 2009

    Posted 15 Apr 2011 Link to this post

    I have two updowns and a label.  The label is updated with the sum of the values entered into the two updowns.  I wired up the ValueChanged event to both updowns to call a method that does the calculation and then put the sum into the label.

    It works, but it appears to behave like a text input in IE such that it only fires when the control loses focus.  The client needs to be able to see the values calculate as they type.

    I tried using KeyDown, but it doesn't work because the UpDown still has focus and the value isn't evulated as changed until the control loses focus.

    Is there a way to work around this?
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 18 Apr 2011 Link to this post

    Hi Gunther,

    The ValueChanged event is fired every time when the user changes the value in the NumericUpDown, even if the focus is still in the control. Alternately, you can try to use the PreviewTextInput event which is fired every time the user types into the TextBox of the NumericUpDown before the ValueChanged event.

    If you still experience difficulties could you please send us your project in order to track down the source of the problem.

    Kind regards,
    Konstantina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sébastien
    Sébastien avatar
    16 posts
    Member since:
    Aug 2012

    Posted 22 Jun 2011 Link to this post

    I have a similar problem to this, but I'm using data binding.
    I have two RadNumericUpDown controls bound to UInt64's on the RadNumericUpDown.ValueProperty property using BindingMode = BindingMode.PropertyChanged. The bound property in my view model is only updated on focus lost. What gives ?

    Thanks,
    Sebastien
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 24 Jun 2011 Link to this post

    Hello Sébastien,

    Could you please give us some more details about this - sending us a sample project will be very helpful.

    Looking forward to your reply.

    Regards,
    Konstantina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Sébastien
    Sébastien avatar
    16 posts
    Member since:
    Aug 2012

    Posted 29 Jun 2011 Link to this post

    I whipped up a sample real fast. Turns out the PropertyChanged trigger works fine when using the Up and Down buttons within the control, but it doesn't work when typing a value directly using the keyboard.

    MainWindow.xaml:

    <Window x:Class="TelerikNumericUpDownBug.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <telerik:RadNumericUpDown x:Name="m_numericControl" NumberDecimalDigits="0"></telerik:RadNumericUpDown>
            <TextBox x:Name="m_textBox" IsEnabled="False"></TextBox>
        </StackPanel>
    </Window>

    MainWindow.xaml.cs:

    using System;
    using System.Windows;
    using System.Windows.Data;
    using Telerik.Windows.Controls;

    namespace TelerikNumericUpDownBug
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public UInt32 NumericValue
            {
                get
                {
                    return m_numericValue;
                }
                set
                {
                    m_numericValue = value;

                    m_textBox.Text = m_numericValue.ToString();
                }
            }
            private UInt32 m_numericValue = 0;

            public MainWindow()
            {
                InitializeComponent();

                Binding binding = new Binding( "NumericValue" );
                binding.Source = this;
                binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                m_numericControl.SetBinding( RadNumericUpDown.ValueProperty, binding );
            }
        }
    }
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 04 Jul 2011 Link to this post

    Hi Sébastien,

    Thank you for the code-snippet.

    In order to make it work you have to set the UpdateValueEvent property of the NumericUpDown control to PropertyChanged

    Hope this helps.

    Regards,
    Konstantina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Sébastien
    Sébastien avatar
    16 posts
    Member since:
    Aug 2012

    Posted 04 Jul 2011 Link to this post

    Thanks, that worked.
    Might want to consider using the UpdateSourceTrigger instead of duplicating where this has to be set.

Back to Top
UI for WPF is Visual Studio 2017 Ready