This project has moved and is read-only. For the latest updates, please go here.

IntegerUpDown ValueChanged event

Apr 4, 2011 at 11:38 PM

I just fetched the latest toolkit and switch my application from NumericUpDown to IntegerUpDown and now I'm having trouble with my ValueChanged events.

I'm getting: "No overload for 'LastMonthsEdit_ValueChanged' matches delegate 'System.Windows.RoutedPropertyChangedEventHandler<int?>"

I assume this is telling me to change my event handler but I can not get it to work.

Any help would be appreciated.

Paul P.



Apr 5, 2011 at 12:57 AM

Can you provide your event handler signature?

Apr 5, 2011 at 1:06 AM

Never mind.. I figured it out.

After the change, there were too many errors with the event handlers and it confused me.

I solved it by changing all my event declaration from:

private void LastMonthsEdit_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)



private void LastMonthsEdit_ValueChanged(object sender, RoutedPropertyChangedEventArgs<int?> e)

I assume that is the correct solution.

Paul P.

Apr 5, 2011 at 1:07 AM

Yes, that is the correct solution.

Apr 5, 2011 at 1:27 AM

Am I supposed to be able to enter a non-integer value using the keyboard into an IntegerUpDown control?

Apr 5, 2011 at 2:50 AM

Yes you are, but it will not accept invalid characters.  You are not restricted to numeric characters to support format strings such as currency.

Apr 6, 2011 at 1:49 AM


1) On my original issue of IntegerUpDown ValueChanged event, in the XAML, when I right click on the event handler and "Navigate to Event Handler", I keep getting "An unknown error occurred why trying to navigate to event handler. Please rebuild your project and try again." The type of the event is UpDownBase`1.ValueChanged as shown when I mouse over the event in the XAML. The code compiles fine but I don't seem to be able to navigate to an existing or new Value Changed event handler. I have a similar problem with the DateTimeUpDown control as well.

2) I seem to be able to type just about any character in an IntegerUpDown control but I get an FormatException in the NumericUpDown.ParseInt routine. Do I need to specify a FormatString? If so, what is the syntax?

Am I doing something wrong here?

Paul P.


Apr 6, 2011 at 2:06 AM
Edited Apr 6, 2011 at 2:07 AM

1) This is actually a bug in Visual Studio.  Visual Studio throws an error anytime you try to create an event handler that uses generics in XAML.  I may change the event to use object instead of T, but then you would have to cast your value in the event handler.  Do you feel this is acceptable?  For now you can only create them in code-behind.

2) Could you provide an simple example to reproduce the error.  When invalid characters are typed, it should simply revert back to the original value.

Apr 6, 2011 at 2:13 AM

1) It currently is a little more difficult to create and navigate to the event handlers.

2) The IntegerUpDown seemed to accept just about ANY key. For example, I was able to type:"1123asdadadasdaxxaaxadadadadadadqwe246576;;098"

And here is the call stack:

  [External Code] 
> WPFToolkit.Extended.dll!Microsoft.Windows.Controls.NumericUpDown<int?>.ParseInt(string text, System.IFormatProvider cultureInfo) Line 185 + 0x14 bytes C#
  WPFToolkit.Extended.dll!Microsoft.Windows.Controls.IntegerUpDown.ConvertTextToValue(string text) Line 59 + 0x60 bytes C#
  WPFToolkit.Extended.dll!Microsoft.Windows.Controls.Primitives.UpDownBase<int?>.SyncTextAndValueProperties(System.Windows.DependencyProperty p, string text) Line 255 + 0x26 bytes C#
  WPFToolkit.Extended.dll!Microsoft.Windows.Controls.Primitives.UpDownBase<int?>.OnTextChanged(string oldValue, string newValue) Line 183 + 0x1c bytes C#
  WPFToolkit.Extended.dll!Microsoft.Windows.Controls.Primitives.InputBase.OnTextChanged(System.Windows.DependencyObject o, System.Windows.DependencyPropertyChangedEventArgs e) Line 47 + 0x6e bytes C#
  [External Code] 
  DocentScheduling.exe!DocentScheduling.MainWindow.DocentSchedulingCommand_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) Line 291 + 0x12 bytes C#
  DocentScheduling.exe!DocentScheduling.MainWindow.DocentSchedulingButton_Click(object sender, System.Windows.RoutedEventArgs e) Line 137 + 0x12 bytes C#
  [External Code] 

Apr 6, 2011 at 2:21 AM

1) I will probably get rid of the generic event signature and just use object.

2) Is the Value null or is it set to a numeric value first?

Apr 6, 2011 at 2:29 AM

What .NET version are you using?  Does the application crash?  Do this happen only in debug, or does it occur if you run the application from outside visual studio?  If it only happens during debugging, make sure you check you debugging exception options.  You may have a check mark next to the CLR exceptions.  I cannot duplicate an unhandled exception.

Apr 6, 2011 at 2:52 AM

1) The value of the IntegerUpDown control was 0 initially (amoung other values but not null).

2) .NET 4

3) Run outside VS 2010, the program runs without problem

4) My VS 2010 configuration is the default configuration (out of the box). 

5) I've disabled CLR interrupts and now I don't have an exception problem.

Apr 6, 2011 at 3:07 AM

I am glad your issue is reolved.  I will change the ValueChanged event signature to use object tomorrow.

Oct 17, 2012 at 1:37 PM

I used this FormatString for degrees:  "0 º"

With it, I get it to display values like "180 º". The problem comes when typing into the IntegerUpDown: the ValueChanged method isn't called when you keep the symbol "º". It seems that the control cannot figure out that the symbol is part of the formatting and it just doesn't update the value.