title: How to Bind on a Property by String as Propertyname
body: <p>Hi i want to Bind to an "unknown" (i only get a string) Property in Xaml </p>
  
  <p>at first i wrote an IValueConverter but you can't bind to ConverterParameter
  so i rewrite it as IMultiValueConverter but now i'm unable to  figure out how to use the <code>&lt;Binding /&gt;</code> with out Path
  or my i'm wrong?</p>
  
  <p>if you write <code>&lt;TextBlock Text="{Binding}" /&gt;</code> you will get the object Person
  and with <code>{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=View.Columns[0].Header}}</code> i'm able to access the Header Text of the first row</p>
  
  <p>now i'm only need to combine both and a will get the Property right?</p>
  
  <p>my test Xaml code:</p>
  
  <pre><code>&lt;UserControl x:Class="Frameworktest.View.auswahl"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               xmlns:local="clr-namespace:Frameworktest"&gt;
      &lt;UserControl.Resources&gt;
          &lt;local:toPropertyConverter x:Key="PropertyConverter"/&gt;
      &lt;/UserControl.Resources&gt;
      &lt;StackPanel&gt;
          &lt;!--...--&gt;
          &lt;Border BorderThickness="5" HorizontalAlignment="Left" VerticalAlignment="Top" 
                  BorderBrush="Green" CornerRadius="5"&gt;
              &lt;ListView  Name="listView1"  IsSynchronizedWithCurrentItem="False" 
                         ItemsSource="{Binding Items, UpdateSourceTrigger=PropertyChanged}" &lt;!--ObservableCollection&lt;Person&gt;--&gt;
                         SelectedItem="{Binding selectedItem, UpdateSourceTrigger=PropertyChanged}"&gt;
                  &lt;ListView.View&gt;
                      &lt;GridView&gt;
                          &lt;GridViewColumn Header="Name"&gt;
                              &lt;GridViewColumn.CellTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;TextBlock Margin="1"&gt;
                                          &lt;TextBlock.Text&gt;
                                              &lt;MultiBinding Converter="{StaticResource PropertyConverter}"&gt;
                                                  &lt;Binding /&gt;&lt;!-- How do i {Binding} here?--&gt;
                                                  &lt;Binding Source="{Binding RelativeSource={Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=View.Columns[0].Header}}" /&gt;
                                              &lt;/MultiBinding&gt;
                                          &lt;/TextBlock.Text&gt;
                                      &lt;/TextBlock&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/GridViewColumn.CellTemplate&gt;
                          &lt;/GridViewColumn&gt;
  
                          &lt;GridViewColumn Header="Firstname" &gt;
                              &lt;GridViewColumn.CellTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;TextBlock Margin="1" Text="{Binding Path=Name}" Width="100"/&gt;&lt;!--works--&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/GridViewColumn.CellTemplate&gt;
  
                          &lt;/GridViewColumn&gt;
                          &lt;GridViewColumn Header="Age"&gt;
                              &lt;GridViewColumn.CellTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;TextBlock Margin="1" Text="{Binding Age}" Width="50"/&gt;&lt;!--works--&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/GridViewColumn.CellTemplate&gt;
                          &lt;/GridViewColumn&gt;
                     &lt;/GridView&gt;
                  &lt;/ListView.View&gt;
              &lt;/ListView&gt;
          &lt;/Border&gt;
      &lt;/StackPanel&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>the Converter:</p>
  
  <pre><code>public class toPropertyConverter : IMultiValueConverter 
  {
      public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
      {
          return values[0].GetType().GetProperty((string)values[1]);
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>The Model</p>
  
  <pre><code>public class Person : MBase, IContains
  {
  private string _name;
  
  public string  Name
  {
      get { return _name; }
      set { _name = value;
      RaisePropertyChanged(() =&gt; Reg(() =&gt; Name));
      }
  }
  
  private string _firstname;
  public string  Firstname
  {
      get { return _firstname; }
      set
      {
          _firstname = value;
          RaisePropertyChanged(() =&gt; Reg(() =&gt; Firstname));
      }
  }
  
  private int _age;
  
  public int Age
  {
      get { return _age; }
      set
      {
          _age = value;
          RaisePropertyChanged(() =&gt; Reg(() =&gt; Age));
      }
  }
  
  public bool Contains(string text)
  {
      string pers = string.Format("{0} {1}", Firstname, Name);
  
      return pers.Contains(text);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <h2><strong>Update my current Multibindung</strong></h2>
  
  <pre><code>&lt;MultiBinding Converter="{StaticResource PropertyConverter}"&gt;
         &lt;Binding Path="."/&gt;
         &lt;Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}" Path="View.Columns[0].Header}}" /&gt; &lt;!-- doesn't contain the word "Name" like i suspected --&gt;
  &lt;/MultiBinding&gt;
  </code></pre>
  
  <h2><strong>LAST Update</strong></h2>
  
  <p>it is a dead end <strong>in my case</strong> you can't Bind from the GridViewColumn.CellTemplate to the specific Column Header Value</p>