0
Answer

How to apply a validation rule for control in WPF-MVVM

jeevan mummadi

jeevan mummadi

11y
1.6k
1
Hi All,

Currently I am working on WPF with MVVM patern. I created one sample apps like this

View
------

<TextBox Grid.Row="0" Grid.Column="1" Width="100" HorizontalAlignment="Center" Text="{Binding Student.Name, Mode=TwoWay}"/>

ViewModel
--------------

public Student Student
        {
            get 
            {
                return _student;
            }
            set 
            {
                _student = value;
                NotifyPropertyChanged("Student");
            }
        }


Model
--------
public class Student
    {
        public string Name { get; set; }
        
    }

Can you please any one explain about how to validate a property for example "Name" 
We have to apply validation rule in ViewModel or Model level.