Home Forums WPF controls Xceed DataGrid for WPF 6.1.16565.14160 Crash if columns bound on decimals are displayed as empty string

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • cviron
    Participant
    Post count: 3
    #44477 |

    We installed the lastest WPF DataGrid version: 6.1.16565.14160 and we found a crash in one of our grid.

    We have a grid displaying amounts bound on values that are Decimal. Our requirement is that if the amount is 0$, then display an empty string instead.
    As soon as we load the grid, or scroll the grid to display new records with empty amounts, we receive the below crash error.

    After installing the new version of Xceed we get this error when using a converter in our XAML form :

    Input string was not in a correct format.
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
    at System.Convert.ToDecimal(String value, IFormatProvider provider)
    at System.String.System.IConvertible.ToDecimal(IFormatProvider provider)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at Xceed.Wpf.Controls.ValueRangeTextBox.ConvertValueToDataType(Object value, Type type)
    at Xceed.Wpf.Controls.ValueRangeTextBox.ValueCoerceValueCallback(Object sender, Object value)
    at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
    at Xceed.Wpf.Controls.ValueRangeTextBox.OnInitialized(EventArgs e)

    Here is the XAML :

    <xcdg:DataGridControl.Columns>

    <xcdg:Column FieldName=”Amount” Title=”Amount”
    Width=”80″ CellHorizontalContentAlignment=”Stretch”
    DisplayMemberBinding=”{Binding Mode=TwoWay, Path=CashCollectionArDistributionDetail.Amount, Converter={tpc:CurrencyGovernConverter}, UpdateSourceTrigger=LostFocus}” />

    <xcdg:Column FieldName=”Interest” Title=”Interest”
    Width=”80″ CellHorizontalContentAlignment=”Stretch”
    DisplayMemberBinding=”{Binding Mode=TwoWay, Path=CashCollectionArDistributionDetail.Interest, Converter={tpc:CurrencyGovernConverter}, UpdateSourceTrigger=LostFocus}” />

    </xcdg:DataGridControl.Columns>

    Public Class CurrencyGovernConverter
    Inherits MarkupExtensionConverterBase(Of CurrencyGovernConverter)
    Implements IValueConverter

    Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert

    Return If(value Is Nothing OrElse Not IsNumeric(value) OrElse CDec(value) = 0,
    String.Empty,
    (New CurrencyConverter()).Convert(CType(value, Decimal), targetType, parameter, culture))

    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
    Return If(IsNumeric(value), CDec(value), 0)
    End Function

    End Class

    All the columns causing this issue are binded to properties of type DECIMAL.

    Fawzi [Xceed]
    Moderator
    Post count: 717

    Hi,

    Could you send me a simple stand alone sample project which reproduces the issue so that I could have a closer look.

    cviron
    Participant
    Post count: 3

    Hi Fawzi,

    I have just sent you my zip file “XCeedDecimalBug.zip” with my sample. I added a ReadMe.txt file that explains you how to reproduce the bug :
    The crash happens when I resize the window so that a column with one String.Empty value is hidden, then expand the window to make this column reappear, crash!

    Hope it helps.
    Thanks.

    cviron
    Participant
    Post count: 3

    Tested successfully with the latest version 6.2.
    This topic can now be closed.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.