PrepAway - Latest Free Exam Questions & Answers

Which code segment should you add to the click event handler of the Button control ?

You are developing WPF application for managing student information… btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml properties : FirstName and LastName. You create the following code segment in the constructor of..

Students = new List<Student>(
new Student[]
{
new Student() { FirstName = “Nicole”, LastName = “Holiday” },

}
);

The DataGrid control displays the list of students unsorted.

You need to ensure that the list of students is sorted by last name.

Which code segment should you add to the click event handler of the Button control ?

PrepAway - Latest Free Exam Questions & Answers

A.
IEnumerable<Student> sortedStudents = Students.OrderBy(s => s.LastName);
dgStudents.ItemsSource = sortedStudents;

B.
IEnumerable<Student> sortedStudents = Students.OrderBy(s => s.LastName).ToList();
dgStudents.ItemsSource = sortedStudents;

C.
Students.Sort();
dgStudents.ItemsSource = Students;

D.
Students.Reverse();
dgStudents.ItemsSource = Students;

One Comment on “Which code segment should you add to the click event handler of the Button control ?

  1. Mr ijs says:

    Full question text:

    You are developing a Windows Presentation Foundation (WPF) application for managing student information. You place a Button control named btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml file. You create a Student class with two properties: FirstName and LastName. You create the following code segment in the constructor of the main window.

    Students = new List(
    new Student[]
    {
    new Student() { FirstName = “Nicole”, LastName = “Holiday” },

    }
    );

    The DataGrid control displays the list of students unsorted.

    You need to ensure that the list of students is sorted by last name.

    Which code segment should you add to the click event handler of the Button control?




    0



    0

Leave a Reply