mvvm을 사용하여 wpf 학습 (ORM으로 EF 사용). 나는이 같은 텍스트 상자의 무리를 결합 내보기에,유효성 검사 실패 wpf mvvm
이제 DB에 TBL_CLIENT 테이블을 반영한 entittyobject (예 -
//---------------ClientNew
public const string ClientNewConst = "ClientNew";
private TBL_CLIENT _clientNew = new TBL_CLIENT();
public TBL_CLIENT ClientNew
{
get
{
return _clientNew;
}
set
{
if (_clientNew == value)
{
return;
}
var oldValue = _clientNew;
_clientNew = value;
// Update bindings, no broadcast
RaisePropertyChanged(ClientNewConst);
}
}
TBL_CLIENT가
: 내보기 모델에서
나는 속성이 클라이언트의 이름 만) :
<TextBox Style="{StaticResource ResourceKey=entryFormTextBox}"
Text="{Binding ClientNew.CLIENT_FIRST_NAME,
ValidatesOnDataErrors=True,
NotifyOnValidationError=true,
ValidatesOnExceptions=True,
UpdateSourceTrigger=LostFocus}"
Grid.Column="1"
Grid.Row="1" />
업데이트 소스에 다른 트리거를 사용해 보았습니다. 아직 유효성 검사가 작동하지 않습니다.
오, 난 내 뷰 모델에 인터페이스 idataerrorinfo 구현 한 않습니다 (하지만 그것 안타하지 ..)
#region IDataErrorInfo Members
string IDataErrorInfo.Error
{
get { throw new NotImplementedException(); }
}
string IDataErrorInfo.this[string columnName]
{
get
{
if (string.IsNullOrEmpty("ClientNew.CLIENT_FIRST_NAME"))
{
return "Client Name is required";
}
return null;
}
}
#endregion
그래서, 질문은 ... 내가 어떻게 내 사건에 대한 idataerrorinfo를 사용하여 가능 유효성 검사로 간단하게 구현할 수 있습니다 , 어디에 각 엔티티 개체에 대한 ModelView 정의 된 별도의 속성을 가지고 있지 않지만 속성을 전체 엔티티 개체 소요됩니까? 사전에
덕분에, 알렉스
감사합니다. – HotFrost