コード例 #1
0
        private void DtgStudents_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (DtgStudents.SelectedItem == null)
            {
                return;
            }
            Student studentFromDb = null;

            var selectedStudent = DtgStudents.SelectedItem as Student;

            try
            {
                studentFromDb = _bll.Get(selectedStudent.Id);
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Could not get the specified student. {exception.Message}");
            }

            TxtFirstName.Text = studentFromDb.FirstName;
            TxtLastName.Text  = studentFromDb.LastName;
            TxtMajor.Text     = studentFromDb.Major;
        }