Question

Int16EditBox IsNullAllowed

Posted 2 months ago by Avatar Ed Stepan

Hi,

I am getting the following errors on DoubleEditBox and Int16EditBox:

System.Windows.Data Error: 6 : 'SystemConvertConverter' converter failed to convert value '<null>' (type '<null>'); fallback value will be used, if available. BindingExpression:Path=AdditionalRates.AdditionalRates.SaturdayRate; DataItem='RatesViewModel' (HashCode=45742585); target element is 'DoubleEditBox' (Name='txtSaturdayFlat'); target property is 'Value' (type 'Nullable'1') InvalidCastException:'System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at MS.Internal.Data.SystemConvertConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'


System.Windows.Data Error: 6 : 'SystemConvertConverter' converter failed to convert value '<null>' (type '<null>'); fallback value will be used, if available. BindingExpression:Path=AdditionalRates.AdditionalRates.SaturdayPercent; DataItem='RatesViewModel' (HashCode=45742585); target element is 'Int16EditBox' (Name='txtSaturdayPercent'); target property is 'Value' (type 'Nullable'1') InvalidCastException:'System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at MS.Internal.Data.SystemConvertConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'

My property SaturdayRate is a Nullable<Decimal> and my SaturdayPercent is a Nullbale<int>

xaml code is:

<editors1:DoubleEditBox Name="txtSaturdayFlat"
Grid.Column="3" Grid.Row="2" Margin="5,5,0,5"
Width="55" SpinnerVisibility="Collapsed"
IsEnabled="{Binding AdditionalRates.SaturdayFlatRateInputIsEnabled, Mode=TwoWay}"
Format="F2" Value="{Binding AdditionalRates.AdditionalRates.SaturdayRate, ValidatesOnDataErrors=True}"
IsNullAllowed="True"
GotFocus="txtSaturdayFlat_GotFocus"
IsReadOnly="{Binding AdditionalRates.IsReadOnlyData, Mode=TwoWay}" />

 

<editors1:Int16EditBox Name="txtSaturdayPercent"
Grid.Column="6" Grid.Row="2" Margin="5,5,0,5"
Width="40" SpinnerVisibility="Collapsed"
IsEnabled="{Binding AdditionalRates.SaturdayPercentInputIsEnabled, Mode=TwoWay}"
Value="{Binding AdditionalRates.AdditionalRates.SaturdayPercent, ValidatesOnDataErrors=True, Mode=TwoWay}"
IsNullAllowed="True"
GotFocus="txtSaturdayPercent_GotFocus"
IsReadOnly="{Binding AdditionalRates.IsReadOnlyData, Mode=TwoWay}"/>

 

Please note the controls and program are operating as expected. The error messages are being displayed in the output window and I'm trying to clear up the errors.


Comments (1)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Ed,

The only thing offhand I can suggest to try is converting your two props to be Nullable<Double> and Nullable<Int16> so they match the types of the respective edit box Value properties.  See if that makes any difference.

If not, it's hard to say what's happening without a simple sample project to debug with.  Could you put together a new simple sample project that shows it happening and send that in the related support ticket you created?  Then we'll have a look at that to see what's going on.  Please exclude the bin/obj folders from the ZIP you send and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support
Information The latest build of this product (2018.1 build 0670) was released 7 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.