title: Binding const member in code behind from xaml in WPF
body: <p>Is there any good way to bind a property to a const value in codebehind?</p>
  
  <p>When I use ComboBox, I usually do this way in xaml and code behind:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;ComboBox Name="cbBuz"&gt;
     &lt;ComboBoxItem Content="foo" Uid="foo" IsSelected="true" /&gt;
     &lt;ComboBoxItem Content="bar" Uid="bar" /&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>Codebehind:</p>
  
  <pre><code>ComboBoxItem item = cbBuz.GetSelectedItem();
  switch (item.Uid)
  {
      case "foo":  ... break;
      case "bar":  ... break;
  }
  </code></pre>
  
  <p>The reason why I chose this way is following:</p>
  
  <ul>
  <li>For localization purpose, Content string should not be used to determine which item is selected during saving and loading a last selected item.</li>
  <li>For simplicity, XAML and code-behind should be connected internal identifier (In this case, Uid).  So that, XAML and Code-behind can be maintained separately.  </li>
  </ul>
  
  <p>However, maintenance-wise, the internal identifier should be defined in one-place like this:</p>
  
  <pre><code>//IDs
  public const string ID_foo = "foo";
  public const string ID_bar = "bar";
  
  ...
  
  //
  switch (item.Uid)
  {
      case ID_foo:  ... break;
      case ID_bar:  ... break;
  }
  </code></pre>
  
  <p>The problem is seemingly property cannot be const value, so there's no way to bind ID_foo and ID_bar to Uid of ComboBoxItem like this:</p>
  
  <pre><code>//If ID_foo and ID_bar are properties, this will work.
  &lt;ComboBox Name="cbBuz"&gt;
     &lt;ComboBoxItem Content="foo" Uid="{Binding ID_foo}" IsSelected="true" /&gt;
     &lt;ComboBoxItem Content="bar" Uid="{Binding ID_bar}" /&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>So, I want to know how to solve this issue.
  Or, is there any better way to implement it.  It would be nice, too.</p>
  
  <p>Best,</p>