Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Handled Exceptions in XamNumericEditor causes performance problem
posted

Hi there!

I'm using a XamNumericEditor to edit a decimal property on my ViewModel. The ValueType is set to System.Decimal. While debugging from visual studio, the control is extremely unresponsive. I investigated using profiling tools and such and discovered that the control was causing a lot of exceptions to be thrown. I disabled the "Just my Code" setting and enabled managed breakpoints and discovered that this exception is thrown nearly constantly (10-15 times per keystroke):

System.FormatException occurred
  Message=Input string was not in a correct format.
  Source=mscorlib
  StackTrace:
       at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   Infragistics3.Wpf.Editors.v10.1.dll!Infragistics.Windows.Editors.FractionPart.GetFractionValue() + 0x13b bytes   
     Infragistics3.Wpf.Editors.v10.1.dll!Infragistics.Windows.Editors.FractionPart.CanSpin(bool up = true) + 0x52 bytes   
     Infragistics3.Wpf.Editors.v10.1.dll!Infragistics.Windows.Editors.EditInfo.CanSpin(bool up = true, object amount) + 0x130 bytes   
     Infragistics3.Wpf.Editors.v10.1.dll!Infragistics.Windows.Editors.EditInfo.CurrentState.get() + 0x396 bytes

It performs much better outside of the debugger which probably explains why it was missed during testing (assuming you tested the scenario :-)).

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    You can set the ValueType property of the editor to Decimal so that it does not try to parse from Double (which is the default for XamNumericEditor).

    xmlns:sys="clr-namespace:System;assembly=mscorlib"

            <igEditors:XamNumericEditor Value="{Binding Decimal}" ValueType="{x:Type sys:Decimal}" />

    You can also use XamCurrencyEditor directly.

Children
No Data