Combobox and IDataErrorInfo

317 views Asked by At

This is my problem. When I select an item from the combobox, (combobox is populated) I have always red outline.

Why ?

<ComboBox x:Name="Cmb_USER" 
          TabIndex="5" 
          ItemsSource="{Binding User_USER, 
          ValidatesOnExceptions=True,
          ValidatesOnDataErrors=True,NotifyOnValidationError=True}" 
          IsEditable="True"      
          DisplayMemberPath ="DescUser" 
          Text="{Binding Path=USER}" Margin="114,105,98,179"/>
    Public Property User_USER As ObservableCollection(Of Model_User)
Private p_USER As String
Public Property USER() As String
    Get
        Return p_USER
    End Get
    Set(ByVal value As String)
        p_USER = value
        OnPropertyChanged("USER")
    End Set
End Property
#Region "IDataErrorInfo Members"
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

        Select Case Name
            Case "User_USER"
                If USER = "" Then
                    result = "ERROR"
                End If
        End Select
        Return result
    End Get
End Property
#End Region
1

There are 1 answers

0
Alan392 On BEST ANSWER

Solved .. This is the solution

Public Property USER() As String
Get
    Return p_USER
End Get
Set(ByVal value As String)
    p_USER = value
    OnPropertyChanged("USER")
    OnPropertyChanged("User_USER")
End Set

End Property