<Window
  x:Class="CollectionViewSourceBinding.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:CollectionViewSourceBinding"
  xmlns:compModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
  xmlns:data="clr-namespace:System.Windows.Data;assembly=PresentationFramework" 
  Title="CollectionViewSourceBinding"
  Height="300"
  Width="300">
  <Window.Resources>
    <local:People x:Key="Family">
      <local:Person Name="Tom" Age="11" />
      <local:Person Name="John" Age="12" />
      <local:Person Name="Melissa" Age="38" />
      <local:Person Name="Penny" Age="38" />
    </local:People>

    <local:AgeToRangeConverter x:Key="ageConverter" />
    
    <CollectionViewSource x:Key="SortedGroupedFamily" Source="{StaticResource Family}">
      
      <CollectionViewSource.SortDescriptions>
        <compModel:SortDescription PropertyName="Name" Direction="Ascending" />
        <compModel:SortDescription PropertyName="Age" Direction="Descending" />
      </CollectionViewSource.SortDescriptions>
      
      <CollectionViewSource.GroupDescriptions>
        <data:PropertyGroupDescription PropertyName="Age" Converter="{StaticResource ageConverter}" />
        <data:PropertyGroupDescription PropertyName="Age" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

  </Window.Resources>
  <Grid>
    <ListBox ItemsSource="{Binding Source={StaticResource SortedGroupedFamily}}" DisplayMemberPath="Name">
      <ListBox.GroupStyle>
        <x:Static Member="GroupStyle.Default" />
      </ListBox.GroupStyle>
    </ListBox>
  </Grid>
</Window>
