示例#1
0
 /// <summary>
 /// Constructor for editting mode.
 /// </summary>
 /// <param name="role">Sets the role of the window's actions.</param>
 /// <param name="studentInfo">Info about target student.</param>
 public StudentInfoWindowViewModel(StudentInfoWindowRole role, Student studentInfo)
 {
     // Set command action according to window role.
     ConfirmStudentInfoCommand = role == StudentInfoWindowRole.Add ? new RelayCommand(AddStudent)
                                                             : new RelayCommand(EditStudent);
     // Set up input fields with target student's info when window opens.
     InputId        = studentInfo.Id;
     InputFirstName = studentInfo.FirstName;
     InputLastName  = studentInfo.LastName;
     InputAge       = studentInfo.Age;
     InputGender    = studentInfo.Gender;
 }
 public StudentInfoWindow(StudentInfoWindowRole role, Student studentInfo)
 {
     InitializeComponent();
     DataContext = new StudentInfoWindowViewModel(role, studentInfo);
 }