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
395
Xamdatagrid IDataErrorInfo only works for newly added records
posted

I change my error condition after adding first two records, but instead of all items, I only get error message for newly added ones. 

   <infragistic:XamDataGrid.FieldLayoutSettings>
                                            <infragistic:FieldLayoutSettings AutoGenerateFields="False" 
                                            AutoFitMode="Always" 
                                            AddNewRecordLocation="OnTopFixed"
                                            AllowAddNew="False"
                                            SupportDataErrorInfo="RecordsAndCells"
                                            DataErrorDisplayMode="Highlight"
                                            AllowDelete="True" SelectionTypeRecord="Single"/>
                                        </infragistic:XamDataGrid.FieldLayoutSettings>
                                        <infragistic:XamDataGrid.FieldLayouts>
                                            <infragistic:FieldLayout>
                                                <infragistic:FieldLayout.Fields>
                                                    <infragistic:Field Name="Name" Label="Name"></infragistic:Field>
                                                    <infragistic:Field Name="GuideWeight" Label="Guide weight" Visibility="{infragistic:FieldBinding ShowGuideWeight,  Converter ={StaticResource boltoVis}}">
                                                    </infragistic:Field>

                                                </infragistic:FieldLayout.Fields>
                                            </infragistic:FieldLayout>
                                        </infragistic:XamDataGrid.FieldLayouts>
                                    </infragistic:XamDataGrid>

here is my data grid, and my IDATAErrorinfo code

        private static readonly string[] ValidateProperties =
        {
            nameof(WellLogVersion),
            nameof(GuideWeight),
            nameof(Name)
        };

        public bool IsValid
        {
            get
            {
                foreach (string property in ValidateProperties)
                    if (GetValidationError(property) != null)
                        return false;

                return true;

            }
        }


        public override string GetValidationError(String propertyName)
        {
            string Error = null;
            switch (propertyName)
            {
                case nameof(GuideWeight):

                    Error = Validate(nameof(GuideWeight));

                    break;

                //case nameof(WellLogVersion):
                case nameof(Name):

                    Error = Validate(nameof(WellLogVersion));
                    break;

            }



            return Error;
        }

        private string Validate(string prop)
        {
            var errors = _model.ParentEpbdo.Errors.Where(x => Equals(x.PropertyName, prop));

            string message = "";
            foreach (var error in errors)
            {
                message += PropertyBuilderDOErrorMessages.GetErrorMessage(error.ErrorCode) + Environment.NewLine;
            }

            return message;
        }

what am I missing ?

  • 100
    Offline posted

    Hello,

    IDataErrorInfo interface found in the .NET Framework requires the implementation of the following properties:

     public string this[string columnName] => throw new NotImplementedException();
    
     public string Error => throw new NotImplementedException();

    More information about DataErrorValidation can be read on our website here.

    For further reference, please check the attached sample, where validation of both pre-loaded and newly created entries can be observed.

    Should you have any other questions, please let me know.

    Sincerely,
    Tihomir Tonev
    Associate Software Developer

    4214.sample.zip