组合框和 IDataErrorInfo
Combobox and IDataErrorInfo
这是我的问题。
当我 select 组合框中的一个项目时,(组合框被填充)我总是有红色轮廓。
为什么?
<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
解决了..
这就是解决方案
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
结束属性
这是我的问题。 当我 select 组合框中的一个项目时,(组合框被填充)我总是有红色轮廓。
为什么?
<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
解决了.. 这就是解决方案
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
结束属性