Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Question about sorting a detail table

$
0
0

I originally posted this question here and was referred to this forum.  

I'm just going to start fresh here and ask this question again.  Using WPF and EF, I used the EF wizard to create a master/detail scenario.  A patient is selected from a combo and their dentist appointments displayed in a detail form.  I wish to sort this detail in descending date order.

Example:  Pull dentist info for Mickey Mouse (or any selected patient) and display their appointments in descending date order.  As illustrated below, the dates are in ascending order.

The following xaml was suggested to me (see original post).  I attempted this but the descending order doesn't occur.

Xaml:

<Window.Resources><CollectionViewSource x:Key="TblPatientDemographicViewSource" d:DesignSource="{d:DesignInstance {x:Type local:tblPatientDemographic}, CreateList=True}"/><CollectionViewSource x:Key="TblPatientDemographictblDentistAppointmentsViewSource" 
                Source="{Binding tblDentistAppointments, 
                Source={StaticResource TblPatientDemographicViewSource}}"><CollectionViewSource.SortDescriptions><scm:SortDescription PropertyName="DentistAppointmentDate" Direction="Descending" /></CollectionViewSource.SortDescriptions></CollectionViewSource>

<DataGrid x:Name="TblDentistAppointmentsDataGrid" AutoGenerateColumns="False" 
                              EnableRowVirtualization="True" 
                              ItemsSource="{Binding Source={StaticResource TblPatientDemographictblDentistAppointmentsViewSource}}" 

Code (generated by EF wizard):

Dim TblPatientDemographicViewSource As CollectionViewSource =
            CType(Me.FindResource("TblPatientDemographicViewSource"), CollectionViewSource)

        'sort view by patient name.  
        TblPatientDemographicViewSource.SortDescriptions.Add(New SortDescription("PatientName", ListSortDirection.Ascending))

        'Load data by setting the CollectionViewSource.Source property:
        'TblPatientDemographicViewSource.Source = [generic data source]
        _context.tblPatientDemographics.Load()
        TblPatientDemographicViewSource.Source = _context.tblPatientDemographics.Local

The above makes the combo sort by patient name, which is the desired outcome.  





Thanks.


Viewing all articles
Browse latest Browse all 18858

Trending Articles