7
Vote

NumericUpDown/DataForm bug

description

When editing a item in a DataForm, the Commit button does not become enabled when the NumericUpDown's value is changed using the spinner UNLESS the NumericUpDown's textbox first receives focus. If the user clicks on the spinner without the textbox having focus, the value will change, but the Commit button will not become enabled as it should. (October 2009 Toolkit)
 
e.g.
 
<dataForm:DataField>
<input:NumericUpDown Value="{Binding ITEMCOUNT, Mode=TwoWay}" />
</dataForm:DataField>

comments

louisatwork wrote Dec 9, 2009 at 1:45 PM

The problem is still there in the November 2009 Toolkit. Please fix this issue.

Aquilax wrote Mar 25, 2010 at 9:30 AM

Here how to fix it, extend the NumericUpDown and override the OnSpin method:

protected override void OnSpin(SpinEventArgs e)
{
//Getting focus, so the data form activate itself.
this.Focus();
//Delaying the call to the base method to allow the data form to handle the got focus event.
Action<SpinEventArgs> baseOnSpin = base.OnSpin;
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.Zero;
timer.Tick += (s, ex) => { timer.Stop(); baseOnSpin(e); };
timer.Start();
}