WPF Data Binding and Validation - ArugmentOutOfRangeException

Posts   
 
    
scaless
User
Posts: 22
Joined: 28-Mar-2011
# Posted on: 29-Mar-2011 22:42:19   

This can be disregarded. It was just the VS setting that displaying the exception. After pressing F5 to resume the application, the behavior was as expected.

Issue: I am hoping there is a quick and easy answer to this question. I am using WPF. In my example, I have a text box that is bound to a property ZipCode in the generated entity. The validation rule (generated rule based on oracle precision) throws an ArgumentOutOfRangeException when more than 5 characters are entered. When I enter letters, it does what I expect, which is to highlight the text box and set the tooltip to the error message. I am trying to figure out how to get the character limit validation to behave in the same manner. I have the xaml code and exception information listed below.

** LLBLGen Pro V:** 3.1 Final - TRIAL Runtime Library **V: 3.1.11.318 **.NET Version: 4.0 Template Group: Both Adapter and Selfservicing through the same exception **Oracle V: **10g Oracle Client V: 11.1 Inheritance Hierarchies: None OPD Oracle.DataAccess.dll V: 2.111.7.20

        <Style TargetType="TextBox">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="TextBox.ToolTip"
                                Value="{Binding RelativeSource={RelativeSource Self},
                                                Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>

            <TextBox Margin="5"
                     Text="{Binding Path=ZipCode, 
                                    ValidatesOnDataErrors=True, 
                                    ValidatesOnExceptions=True}">

Exception Info System.ArgumentOutOfRangeException was unhandled by user code Message=The value '974113' is larger than the precision of the field: '5' and will cause an overflow in the database. Parameter name: ZipCode Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20 ParamName=ZipCode StackTrace: at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.ValidateValue(IFieldInfo fieldToValidate, Object& value, Int32 fieldIndex) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityBase2.cs:line 3861 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.SetValue(Int32 fieldIndex, Object value, Boolean performDesyncForFKFields) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityBase2.cs:line 2622 at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.SetValue(Int32 fieldIndex, Object value) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityBase2.cs:line 2571 at DCBS.Applications.Test2.EntityClasses.CpcProviderContactsVEntity.set_ZipCode(Nullable`1 value) in C:\DevPOC\llblgen\DatabaseGeneric\EntityClasses\CpcProviderContactsVEntity.cs:line 788 InnerException: