Products =
new
ObservableCollection<Product>(products);
ProductOptions =
new
ObservableCollection<ProductOption>(options);
ProductsView = CollectionViewSource.GetDefaultView(Products);
ProductsView.GroupDescriptions.Add(
new
PropertyGroupDescription(
"Group"
));
ProductsView.SortDescriptions.Add(
new
SortDescription(
"Name"
, ListSortDirection.Ascending));
ProductOptionsView = CollectionViewSource.GetDefaultView(ProductOptions);
ProductOptionsView.SortDescriptions.Add(
new
SortDescription(
"Option"
, ListSortDirection.Ascending));
<ListBox Grid.Row="1" ItemsSource="{Binding Products}"
DisplayMemberPath="Name"> <ListBox.GroupStyle> <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <TextBlock Foreground="DarkGreen" Text="{Binding Name}" FontStyle="Italic"/> </DataTemplate> </GroupStyle.HeaderTemplate> </GroupStyle> </ListBox.GroupStyle>