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

ValueChanged event doesn't fire as they are typing

6 Answers 978 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
gunther
Top achievements
Rank 1
gunther asked on 15 Apr 2011, 03:32 PM
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?

6 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 18 Apr 2011, 11:54 AM
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
0
Sébastien
Top achievements
Rank 1
answered on 22 Jun 2011, 03:53 PM
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
0
Konstantina
Telerik team
answered on 24 Jun 2011, 11:10 AM
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
0
Sébastien
Top achievements
Rank 1
answered on 29 Jun 2011, 09:28 PM
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 );
        }
    }
}
0
Konstantina
Telerik team
answered on 04 Jul 2011, 03:51 PM
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
0
Sébastien
Top achievements
Rank 1
answered on 04 Jul 2011, 04:58 PM
Thanks, that worked.
Might want to consider using the UpdateSourceTrigger instead of duplicating where this has to be set.

Tags
NumericUpDown
Asked by
gunther
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Sébastien
Top achievements
Rank 1
Share this question
or