Validation Messages [modified]
-
I have implemented validation using IDialogService on INotifyPropertyChanged but its not working properly when i click on save button and after successfull insertion if i ll clear my control then also my validation message display error message. if any boday can help me then i ll be thankfull to him.
Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi
modified on Saturday, May 22, 2010 5:35 AM
-
I have implemented validation using IDialogService on INotifyPropertyChanged but its not working properly when i click on save button and after successfull insertion if i ll clear my control then also my validation message display error message. if any boday can help me then i ll be thankfull to him.
Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi
modified on Saturday, May 22, 2010 5:35 AM
-
You need to post code here to show what you have implemented so far before anyone can help you.
My signature "sucks" today
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