title: Possible to define SortMemberPath conditionally with Converter?
body: <p>I have a DataGrid of which contains a column that is shared by 2 different sortable items in a StackPanel.</p>
  
  <p>These items are both for NameA/NameB and what I want is for the SortMemberPath to change between these two depending on the state of a bool called 'sortByNameB'.</p>
  
  <p>What I was thinking was using a converter with static resource which checks the state of sortByNameB and then returns something to SortMemberPath.. but I'm not sure what should be returned? I tried returning string as "NameA"/"NameB" but this just breaks the sorting.</p>
  
  <p>Relevant XAML:</p>
  
  <pre><code>&lt;DataGridTemplateColumn Header="Names" SortMemberPath="{Binding Converter={StaticResource NameSort}}"&gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel Orientation="Vertical" VerticalAlignment="Center"&gt;
                  &lt;TextBlock Padding="1" HorizontalAlignment="Center"&gt;
                      &lt;Hyperlink NavigateUri="{Binding Path=NameA}" RequestNavigate="Name_RequestNavigate"&gt;
                          &lt;TextBlock Text="{Binding Path=NameA}" Foreground="{Binding RelativeSource={RelativeSource Self}, Path=Text, Converter={StaticResource FGName}}"/&gt;
                      &lt;/Hyperlink&gt;
                  &lt;/TextBlock&gt;
                  &lt;TextBlock Padding="1" HorizontalAlignment="Center"&gt;
                      &lt;Hyperlink NavigateUri="{Binding Path=NameA}" RequestNavigate="Name_RequestNavigate"&gt;
                          &lt;TextBlock Text="{Binding Path=NameB}" Foreground="{Binding RelativeSource={RelativeSource Self}, Path=Text, Converter={StaticResource FGName}}"/&gt;
                      &lt;/Hyperlink&gt;
                  &lt;/TextBlock&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  </code></pre>
  
  <p>Converter:</p>
  
  <pre><code>public class NameSort : IValueConverter {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
          return (ToolView.sortByNameB) ? "NameB" : "NameA";
      }
  }
  </code></pre>