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
210
Validation without IDataError in object
posted

I have a situation where I dynamically build columns and that includes whether a column is required to have data or not.  This is in metadata in another table, so the underlining table has no requirements for data.  It is all created at runtime by reading the configuration. Make sense?  So in following some examples, I created a style for required fields that turns the border read if the value is NULL, and that works fine in showing the red border:

In code creating column:

field.Settings.EditorStyle = (Style)FindResource("RequiredFieldStyle");

In XAML

<Style x:Key="RequiredFieldStyle" TargetType="{x:Type igEditors:ValueEditor}">
            <Style.Setters>
                <Setter Property="ValueConstraint">
                    <Setter.Value>
                        <igEditors:ValueConstraint Nullable="False" />
                    </Setter.Value>
                </Setter>
                <Setter Property="InvalidValueBehavior" Value="RetainValue" />
            </Style.Setters>
            <Style.Triggers>
                <Trigger Property="IsValueValid" Value="false">
                    <Trigger.Setters>
                        <Setter Property="BorderBrush" Value="Red" />
                    </Trigger.Setters>
                </Trigger>
            </Style.Triggers>
        </Style>

 

This works fine for showing the red border if a value isn't set.  However, nothing really enforces the record from being saved because there are no "true" errors in the record.  So I am trying to figure out how to catch something on the RecordUpdating, maybe look through each cell, check the EditorStyle, if it is the RequiredStyle, see if it has a value, and if it doesn't not save.  But EditorStyle is always null.  

So my question is, is this is the best way of doing this?  How can I stop the record from being saved when I really can't impliment IDataError and build all the columns dynamically and set dynamic validation requirements on fields?

Parents
No Data
Reply Children
No Data