Perform the following steps to create a collection data model and bind it to the UI, using a DataGrid control:
- Inside the Solution Explorer, right-click on the project. From the context menu, navigate to Add | Class... to create a class file named Employee.cs.
- Open the Employee.cs file and replace the class implementation with the following code:
public class Employee { public string FirstName { get; set; } public string LastName { get; set; } public string Department { get; set; } }
- Navigate to the MainWindow.xaml.cs file and add the following using statement to define ObservableCollection inside the class:
using System.Collections.ObjectModel;
- Inside the MainWindow class implementation, create a dependency property named Employees, of type ObservableCollection<Employee>, as shared here:
public ObservableCollection<Employee> Employees { get { return (ObservableCollection<Employee>)GetValue(EmployeesProperty); } set...