Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > ValueChanged event doesn't fire as they are typing

Not answered ValueChanged event doesn't fire as they are typing

Feed from this thread
  • gunther Intermediate avatar

    Posted on Apr 15, 2011 (permalink)

    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?

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Apr 18, 2011 (permalink)

    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

    Reply

  • Sébastien avatar

    Posted on Jun 22, 2011 (permalink)

    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

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Jun 24, 2011 (permalink)

    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

    Reply

  • Sébastien avatar

    Posted on Jun 29, 2011 (permalink)

    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 );
            }
        }
    }

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Jul 4, 2011 (permalink)

    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

    Reply

  • Sébastien avatar

    Posted on Jul 4, 2011 (permalink)

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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > ValueChanged event doesn't fire as they are typing
Related resources for "ValueChanged event doesn't fire as they are typing"

WPF NumericUpDown Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]