I have a List List control with grouping and sorting.
Group headings are dates in descending order.
I am trying to figure out how to arrange the grouped items under each group heading in ascending order, but I canโt figure out how to do this or maybe even using ListView.
Here is the XAML that I still have.
Note. ScheduledItemSearchResults is an observable collection of ScheduleItems, each element has a Title and ScheduleDate property.
<Grid x:Name="TxScheduleItemResults" Grid.Column="1"> <Grid.Resources> <CollectionViewSource Source="{Binding ScheduledItemSearchResults}" x:Key="scheduledItems"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Value.ScheduleDateTime" Direction="Descending"/> </CollectionViewSource.SortDescriptions> <CollectionViewSource.GroupDescriptions> <dat:PropertyGroupDescription PropertyName="Value.ScheduleDateTime.Date" /> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> </Grid.Resources> <ListView x:Name="ScheduledItemResultsList" Style="{StaticResource TransparentListViewStyle}" ItemContainerStyle="{StaticResource alternatingListViewItemStyle}" AlternationCount="2" ItemsSource="{Binding Source={StaticResource scheduledItems}}" > <ListView.View> <GridView> <GridViewColumn Header="Scheduled Items" Width="{Binding ElementName=ScheduledItemResultsList, Path=ActualWidth}" > <GridViewColumn.HeaderTemplate> <DataTemplate> <TextBlock Style="{StaticResource ModuleGroupHeader}" Text="{Binding}" /> </DataTemplate> </GridViewColumn.HeaderTemplate> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Value.Title}" Width="200"/> <TextBox Text="{Binding Value.ScheduleDateTime, StringFormat={}{0:HH:mm:ss}}" Width="120"/> </StackPanel> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> <ListView.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Expander IsExpanded="True"> <Expander.Header> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Items[0].Value.ScheduleDateTime.Date, StringFormat={}{0:dd/MM/yyyy}}" FontWeight="Bold" Foreground="Gray" FontSize="22" VerticalAlignment="Bottom" /> <TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" /> <TextBlock Text=" item(s)" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" /> </StackPanel> </Expander.Header> <ItemsPresenter /> </Expander> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </ListView.GroupStyle> </ListView> </Grid>
source share