Vb.net 与datagrid绑定中的验证文本框

Vb.net 与datagrid绑定中的验证文本框,vb.net,validation,mvvm,idataerrorinfo,Vb.net,Validation,Mvvm,Idataerrorinfo,我有一个带有“SelectedItem与SelectRowGrid绑定”的网格 p、 在我的代码中实现了IDataErrorInfo和INotifyPropertyChanged 已修复。 我在MyClass类中更改并移动了此代码 新代码: Public ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error Get

我有一个带有“SelectedItem与SelectRowGrid绑定”的网格

p、 在我的代码中实现了IDataErrorInfo和INotifyPropertyChanged

已修复。 我在MyClass类中更改并移动了此代码

新代码:

        Public ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error
        Get
            Return Nothing
        End Get
    End Property
    Default Public ReadOnly Property Item(ByVal Name As String) As String Implements System.ComponentModel.IDataErrorInfo.Item
        Get
            Dim result As String = Nothing
            If Name.Equals("Id_Cli") Then
                If String.IsNullOrEmpty(Me.Id_Cli) Then
                    Return "Error !"
                End If
            End If
            If Name.Equals("Desc") Then
                If String.IsNullOrEmpty(Me.Desc) Then
                    Return "Error !"
                End If
            End If

            Return result
        End Get
    End Property
                <TextBox Grid.Column="1"  Grid.Row="0" Text="{Binding SelectRowGrid.Id_Cli, 
                UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, 
                ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Margin="4,4,4,4"  MaxLength="11"/>

            <TextBox Grid.Column="1"  Grid.Row="1" Text="{Binding SelectRowGrid.Desc, 
                UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, 
                ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Margin="4,4,4,4"   MaxLength="100"/>
        Public ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error
        Get
            Return Nothing
        End Get
    End Property
    Default Public ReadOnly Property Item(ByVal Name As String) As String Implements System.ComponentModel.IDataErrorInfo.Item
        Get
            Dim result As String = Nothing
            If Name = "SelectRowGrid" Then

                If SelectRowGrid IsNot Nothing Then
                    If IsNothing(SelectRowGrid.Id_Cli) Then
                        result = "Item number cannot be blank!"
                    End If
                    If IsNothing(SelectRowGrid.Desc) Then
                        result = "Item number cannot be blank!"
                    End If
                End If
            End If
            Return result
        End Get
    End Property
        Public ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error
        Get
            Return Nothing
        End Get
    End Property
    Default Public ReadOnly Property Item(ByVal Name As String) As String Implements System.ComponentModel.IDataErrorInfo.Item
        Get
            Dim result As String = Nothing
            If Name.Equals("Id_Cli") Then
                If String.IsNullOrEmpty(Me.Id_Cli) Then
                    Return "Error !"
                End If
            End If
            If Name.Equals("Desc") Then
                If String.IsNullOrEmpty(Me.Desc) Then
                    Return "Error !"
                End If
            End If

            Return result
        End Get
    End Property