2
this article 다음 목록보기에서 정렬을 구현했습니다. 창이 열릴 때 내 목록을 기본 정렬로 가져 오려면 어떻게해야합니까?기본 정렬 방법 wpf listview
public MainWindow()
{
InitializeComponent();
SortCustomerList("CustomerName", ListSortDirection.Ascending);
}
을 ...하지만 난 개체의 인스턴스로 설정되지 않았습니다 개체 참조 "의 내부를 제외하고 ..."호출 대상이 예외를 Throw했습니다 "받고 있어요 : 나는 시도했다. "
[편집] 나는 제안 된대로로드 된 이벤트로 정렬 호출을 이동했지만 여전히 예외가 발생합니까? 정렬 메소드 및로드 된 이벤트는 다음과 같습니다.
private void SortCustomerList(string sortBy, ListSortDirection direction)
{
ICollectionView dataView = CollectionViewSource.GetDefaultView(customersListView.ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
private void mainWindow_Loaded(object sender, RoutedEventArgs e)
{
SortCustomerList("CustomerName", ListSortDirection.Ascending);
}
Clear() 메소드에서 실패합니다.
의견을 보내 주셔서 감사합니다.
감사합니다. 정렬 된 메서드 호출을로드 된 이벤트로 옮겨 보았지만 예외가 발생했습니다. – CraigV
SorCustomerList의 첫 번째 줄에 중단 점을 설정하고 null을 확인합니다. – Paul