Dim customer As Customer = TryCast(InPanel.CurrentItem, Customer)
If customer IsNot Nothing Then
Dim errorList = New ObservableCollection(Of ErrorInfo)()
If customer.名前 IsNot Nothing AndAlso String.IsNullOrWhiteSpace _
(customer.名前.ToString()) Then
errorList.Add(New ErrorInfo() With {
.ErrorInputName = "名前",
.ErrorContent = "このフィールドは空白にできません。"
})
End If
If customer.重量 > 150 Then
errorList.Add(New ErrorInfo() With {
.ErrorInputName = "重量",
.ErrorContent = "値が範囲外です。"
})
End If
InPanel.ValidationErrors = errorList
If errorList.Count > 0 Then
e.Cancel = True
End If
End If