title: WPF DataGridTemplateColumn sorting issue
body: <p>I know, lots of topics about that, but I couldn't find any resolution for my issue.</p>
  
  <p>The ViewModel has a bool "UserNotification". The Column is showing a mail icon in the header if there is one or more rows with UserNotificatoin=true. Each row shows the same mail icon if the entry has a notification. </p>
  
  <p>I'm using SortMemberPath="UserNotification" and tried all variations of SortDirection, but the behaviour is always the same:
  When the user clicks once on the column header, the entries with UserNotification=true are sorted to the end, just the second click brings them on top. We need them on top with just one click. </p>
  
  <p>For several reasons, we didn't use CollectionView but an ObservableCollection for the member "TradesView", and fill it with filtered entries (no sorting in the Collection itself). This should not be the problem, because the next column contains the Id (integer), and the sorting works perfectly fine (one click on the header brings the smallest number to the top). </p>
  
  <p>Here is the xaml code: </p>
  
  <pre><code>&lt;DataGrid Name="Blotter"
                  ItemsSource="{Binding TradesView}"
                  SelectedItem="{Binding Path=SelectedTrade, Mode=TwoWay}"
                  IsReadOnly="True"
                  AutoGenerateColumns="False"
                  CanUserSortColumns="True"
                  ScrollViewer.CanContentScroll="True"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                  SelectionMode="Single"
                  SelectionUnit="FullRow"
                  VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
                  GridLinesVisibility="All"
                  HorizontalGridLinesBrush="LightGray"
                  VerticalGridLinesBrush="LightGray"&gt;
              &lt;DataGrid.InputBindings&gt;
                  &lt;KeyBinding Key="Enter" Command="{Binding EditTradeCommand}"/&gt;
                  &lt;KeyBinding Key="Delete" Command="{Binding DeleteTradeCommand}"/&gt;
                  &lt;KeyBinding Key="F5" Command="{Binding RefreshTradesCommand}"/&gt;
              &lt;/DataGrid.InputBindings&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTemplateColumn SortMemberPath="UserNotification" SortDirection="Descending" Width="Auto"&gt;
                      &lt;DataGridTemplateColumn.Header&gt;
                          &lt;Image Source="../Resources/Mail.ico" Width="16" Height="16"
                                 Visibility="{Binding ElementName=Blotter,
                                                      Path=DataContext.GlobalNotification, 
                                                      Converter={StaticResource BooleanToVisibilityConverter}}"/&gt;
                      &lt;/DataGridTemplateColumn.Header&gt;
                      &lt;DataGridTemplateColumn.CellStyle&gt;
                          &lt;Style TargetType="DataGridCell"&gt;
                              &lt;Setter Property="VerticalContentAlignment" Value="Center"/&gt;
                              &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt;
                              &lt;EventSetter Event="MouseDoubleClick" Handler="Blotter_OnMouseDoubleClick"/&gt;
                          &lt;/Style&gt;
                      &lt;/DataGridTemplateColumn.CellStyle&gt;
                      &lt;DataGridTemplateColumn.CellTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Image Source="../Resources/Mail.ico" Width="16" Height="16"
                                     Visibility="{Binding UserNotification, 
                                  Converter={StaticResource BooleanToVisibilityConverter}}"/&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellTemplate&gt;
                  &lt;/DataGridTemplateColumn&gt;
                  &lt;DataGridTextColumn Header="Id" SortMemberPath="TradeId" Width="Auto" Binding="{Binding TradeId}" /&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>I tried a lot of options - I even changed UserNotification to an integer, because the Id column works. But it ended in the same behaviour. I also tried a normal CheckBoxColumn without success. So I don't know if it has to do with the implementation of the TemplateColumn itself. By the way - I already tried it without DataGridTemplateColumn.Header and DataGridTemplateColumn.CellStyle.</p>