假设我有员工类的ObservableCollection
public ObservableCollection<Employee> employeeCollection = new ObservableCollection<Employee>();
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public double MobileNumber { get; set; }
public string City { get; set; }
public int Age { get; set; }
public Employee() {}
}
我现在正在尝试通过用户从组合框中进行适当选择来对ObservableCollection
(“employeeCollection”)进行排序[它将是....按FirstName排序....按MobileNumber排序等]。
并且需要返回已排序的ObservableCollection。这意味着它不能以“var”的形式存在,而应该是ObservableCollection<Employee>
。
因此,我可以将其重新分配给“ItemsControl”
的“ItemsSource”
属性......
谢谢......