.
, DependencyProperty (.. ), , / ( ... .. Text TextBox (nb , )).
UpdateSourceTrigger="Explicit" Target (.. Text TextBox) (, ViewModel/model).... ( ).
, , "" IDataErrorInfo , ""... ... adorner TextBox ( ErrorTemplate).... , .... .
... .
IDataErrorInfo, , .
, ... IDataErrorInfo... .
UpdateSource Validator, ( Loaded true, ).
- :
public class CustomerViewModel : IDataErrorInfo
{
public bool DoValidation { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Error
{
get
{
if (DoValidation)
{
if (error on any properties)
return "error on these .....";
}
return null;
}
}
public string this[string columnName]
{
get
{
if (!DoValidation)
{
return null;
}
string result = null;
if (columnName == "FirstName")
{
if (string.IsNullOrEmpty(FirstName))
result = "Please enter a First Name";
}
if (columnName == "LastName")
{
if (string.IsNullOrEmpty(LastName))
result = "Please enter a Last Name";
}
return result;
}
}
}
DoValidation Loaded.