private void lstHourly_Sorting(object sender, Microsoft.Windows.Controls.DataGridSortingEventArgs e) { try { ICollectionView view = CollectionViewSource.GetDefaultView(lstHourly.ItemsSource); e.Column.SortDirection = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Handled = true; view.SortDescriptions.Clear(); view.SortDescriptions.Insert(0, new SortDescription() { PropertyName = "isTotalRow", Direction = ListSortDirection.Descending }); if (e.Column.SortMemberPath == "Day") { view.SortDescriptions.Insert(1, new SortDescription() { PropertyName = "Date", Direction = e.Column.SortDirection.Value }); } else { view.SortDescriptions.Insert(1, new SortDescription() { PropertyName = e.Column.SortMemberPath, Direction = e.Column.SortDirection.Value }); } view.Refresh(); } catch (Exception Ex) { ExceptionManager.Publish(Ex); } }
// private void btnExport1_Click(object sender, RoutedEventArgs e) // { // DataTable dtSite = new DataTable(); // DataSet dtsiteinter = new DataSet("table"); // dtsiteinter.Tables.Add(dtAnalysisDetails.Copy()); // using (CReportViewer cReportViewer = new CReportViewer()) // { // cReportViewer.ShowSiteIntegorration("SiteIntegorrationReport", dtAnalysisDetails.Copy()); // cReportViewer.ShowDialog(); // } // } private void lstAnalysisDetails_Sorting_1(object sender, Microsoft.Windows.Controls.DataGridSortingEventArgs e) { try { ICollectionView view = CollectionViewSource.GetDefaultView(lstAnalysisDetails.ItemsSource); ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; e.Handled = true; view.SortDescriptions.Clear(); view.SortDescriptions.Insert(0, new SortDescription() { PropertyName = "IsTotalRow", Direction = ListSortDirection.Descending }); view.SortDescriptions.Insert(1, new SortDescription() { PropertyName = e.Column.SortMemberPath, Direction = direction }); view.Refresh(); } catch (Exception Ex) { ExceptionManager.Publish(Ex); } }