title: Binding ComboBoxes to enums... in Silverlight!
body: <p>So, the web, and StackOverflow, have plenty of nice answers for how to bind a combobox to an enum property in WPF. But Silverlight is missing all of the features that make this possible :(. For example:</p>
  
  <ol>
  <li>You can't use a generic <a href="http://www.ageektrapped.com/blog/the-missing-net-7-displaying-enums-in-wpf/" rel="noreferrer"><code>EnumDisplayer</code></a>-style <code>IValueConverter</code> that accepts a type parameter, since Silverlight doesn't support <code>x:Type</code>.</li>
  <li>You can't use <code>ObjectDataProvider</code>, like in <a href="http://blogs.msdn.com/wpfsdk/archive/2007/02/22/displaying-enum-values-using-data-binding.aspx" rel="noreferrer">this approach</a>, since it doesn't exist in Silverlight.</li>
  <li>You can't use a custom markup extension like in the comments on the link from #2, since markup extensions don't exist in Silverlight.</li>
  <li>You can't do a version of #1 using generics instead of <code>Type</code> properties of the object, since generics aren't supported in XAML (and the hacks to make them work all depend on markup extensions, not supported in Silverlight).</li>
  </ol>
  
  <p>Massive fail!</p>
  
  <p>As I see it, the only way to make this work is to either</p>
  
  <ol>
  <li>Cheat and bind to a string property in my ViewModel, whose setter/getter does the conversion, loading values into the ComboBox using code-behind in the View.</li>
  <li>Make a custom <code>IValueConverter</code> for every enum I want to bind to.</li>
  </ol>
  
  <p>Are there any alternatives that are more generic, i.e. don't involve writing the same code over and over for every enum I want? I suppose I could do solution #2 using a generic class accepting the enum as a type parameter, and then create new classes for every enum I want that are simply</p>
  
  <pre><code>class MyEnumConverter : GenericEnumConverter&lt;MyEnum&gt; {}
  </code></pre>
  
  <p>What are your thoughts, guys?</p>