title: Bind textblock to dictionary value for key in XAML?
body: <p>I have a model with an enum property (in this case, related to Export Control Regulations).  When displaying the value to the user, I want to show a corresponding string.  Sometimes this is in ComboBox (where the user can select a value), and sometimes it is in a TextBlock (where it is read-only).</p>
  
  <p>Example: for <code>ExportRegulationType.EAR</code>, I want to display <code>"EAR"</code>, while for <code>ExportRegulationType.DoNotExport</code>, I want to display <code>"Do Not Export"</code>.  Note that I don't have any language localization needs, but I recognize the issue...</p>
  
  <p>Currently, in my ViewModel, I have a property that returns a string based on the current enum value, and also another property that returns a <code>Dictionary&lt;ExportRegulationType, string&gt;</code>.  For the ComboBoxes, I can bind <code>ItemsSource</code> to the dictionary property, and for the TextBlocks, I can bind to the string property.  This works, but is kind of clumsy.</p>
  
  <p>Two questions:</p>
  
  <p>1) It seems to me that I should be able to declare the dictionary (with keys and values) as a static resource in XAML (probably in App.xaml), and use that for the ItemsSource for the ComboBox version.  However, I can't figure out how to declare and reference such a thing.  How can I do that?</p>
  
  <p>2) Assuming the above is in place, I would think I could also set up a binding with the textblock, so based on the enum property, it will look up the string in the dictionary.</p>
  
  <p>I have seen the following questions relating to a <a href="https://stackoverflow.com/questions/2981046/wpf-binding-to-items-within-a-dictionary-by-key">static</a> or <a href="https://stackoverflow.com/questions/5414122/how-to-use-enum-as-key-when-binding-a-dictionary-to-many-textblock-on-xaml">dynamic</a> enum value.  The first isn't adequate, and the second isn't answered...</p>
  
  <p>These should be a XAML-only, and will enable me to remove the methods from my ViewModel (having only the one exposed <code>ExportRegulationType</code> enumerated property. Are these possible?</p>
  
  <p><strong>Edit: Additional information:</strong></p>
  
  <p>In the application, I will have many different sets of views, models, and ViewModels.  However, as export control regulations are a common and consistent requirement, I am using composition to keep it DRY.  i.e., Models A and B both have an ExportControl model.  ViewModels A1, A2, B1 and B2 will have an ExportControlViewModel.  The views will have controls bound to the ExportControlViewModel of their ViewModel.  The views will have either a ComboBox or a TextBlock, but not both (Depending on if the user can change the value).</p>