title: Is there a XAML equivalent to nameof?
body: <p>I'm working with DevExpress's WPF tree list view and I came across what I think is a more general problem relating to renaming properties on the objects used as an item source. In the tree list view one is required to specify the ParentFieldName and the KeyFieldName (which are used determine the structure of the tree). These fields are strings. </p>
  
  <p>This has led to issues refactoring the code. For example renaming a property of the objects I am using as an ItemSource will break the tree view as ParentFieldName and KeyFieldName are no longer in sync with the property names. I have worked around this issue by creating properties in my view model "ParentFieldName" and "KeyFieldName" which use <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof" rel="noreferrer">nameof</a> to present the property name to the view.</p>
  
  <p>Here is a cut down version of the control:</p>
  
  <pre><code>    &lt;UserControl
               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:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"              
               d:DesignHeight="300" d:DesignWidth="300"&gt;
        &lt;UserControl.DataContext&gt;
            &lt;ViewModel /&gt;
        &lt;/UserControl.DataContext&gt;
          &lt;dxg:TreeListControl AutoGenerateColumns="AddNew"
                           EnableSmartColumnsGeneration="True" ItemsSource="{Binding Results}"                        
                           SelectionMode="Row"&gt;
              &lt;dxg:TreeListControl.View&gt;
                  &lt;dxg:TreeListView                                   
                                ParentFieldName="{Binding ParentIdFieldName}" KeyFieldName="{Binding NodeIdFieldName}" 
                                ShowHorizontalLines="False" ShowVerticalLines="False"
                                ShowNodeImages="True"/&gt;
              &lt;/dxg:TreeListControl.View&gt;
          &lt;/dxg:TreeListControl&gt;
      &lt;/UserControl&gt;
  </code></pre>
  
  <p>And the viewmodel:</p>
  
  <pre><code>using DevExpress.Mvvm;    
  
  public sealed class ViewModel : ViewModelBase
  {
      public string ParentIdFieldName =&gt; nameof(TreeNode.ParentId);
  
      public string NodeIdFieldName =&gt; nameof(TreeNode.NodeId);
  
      public ObservableCollection&lt;TreeNode&gt; Results
      {
          get =&gt; GetProperty(() =&gt; Results);
          set =&gt; SetProperty(() =&gt; Results, value);
      } 
  }
  </code></pre>
  
  <p>And the tree node:</p>
  
  <pre><code>public sealed class TreeNode
  {
      public int ParentId {get; set;}
      public int NodeId {get; set;}
  }
  </code></pre>
  
  <p>My solution works well but I was wondering if there was a better way of doing this. For example, is there something I can do in XAML which would be equivalent to the nameof call, rather than binding to this ParentIdFieldName and NodeIdFieldName in the view model?</p>
  
  <p>I realize this could be described as an issue with DevExpress's control. However I'm interested in whether the approach I've used to get around this can be improved on. Is there a way I could do this in a more simple way directly in the XAML?  </p>
  
  <p>I apologize in advance if the code I've provided doesn't compile. I've cut down what I'm working with quite considerably to provide an example.</p>