below is used for binding validation
<TextBox x:Name="txtDispalyName" Text="{Binding Path=DisplayName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Grid.Row="1" Height="24" LostFocus="txtDispalyName_LostFocus" Grid.Column="2" Margin="18,2,54,0" VerticalAlignment="Top" TabIndex="0" >
while in code behind on save click i m calling below code
ViewModel.IsError = true;
getBindProperty();
if (ViewModel.Save())
{
IsSaveClose = true;
SaveData();
}
else
{
ViewModel._dialogService.DisplayValidationDialog(ViewModel.Errors);
}
while my validation class is
public class MyViewModel : INotifyPropertyChanged
{
public readonly IDialogService _dialogService;
CultureInfo Culture;
public MyViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
}
private string \_displayName = "";
public bool IsError { get; set; }
public string DisplayName
{
get { return \_displayName ; }
set
{
if (string.IsNullOrEmpty(value))
{
Culture = Thread.CurrentThread.CurrentCulture;
IsError = false;
throw new Exception(Erp3s.Resources.Strings.ResourceManager.GetString("Display Name is required",Culture));
}
\_displayName = value;
OnPropertyChanged("DisplayName");
}
}
private readonly ObservableCollection<ValidationError> \_errors = new ObservableCollection<ValidationError>();
public ObservableCollection<ValidationError> Errors
{
get { return \_errors; }
}
public bool IsViewStateValid()
{
return Errors.Count == 0;
}
public bool Save()
{
if (!this.IsViewStateValid())
{
return false;
//\_dialogService.DisplayValidationDialog(Errors);
}
else
{
return true;
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHand