title: Windows Phone 8.1 : How to add data annotations to enum value types to get the appropriate string
body: <p>I have a Windows Universal App with an enum in it. I use this enum both in my Windows 8.1 and Windows Phone 8.1 projects.</p>
  
  <p>I have already looked at these links
  <a href="https://stackoverflow.com/questions/22957640/windows-phone-8-enums-dataannotations">Windows Phone 8 - enums &amp; DataAnnotations</a> 
  But this seems to be for Windows Phone 8 Silverlight</p>
  
  <p>Here is my enum</p>
  
  <pre><code>   enum MyEnum
      {
           [Display(Description="Move forward")]
           Forward,
           [Display(Description="Move Backward")]
           Backward
      }
  </code></pre>
  
  <p>The EnumHelper that takes the enum value and returns the description is as follows</p>
  
  <pre><code>    public static T GetAttribute&lt;T&gt;(this Enum enumValue)
          where T : Attribute
      {
          return enumValue
              .GetType()
              .GetTypeInfo()
              .GetDeclaredField(enumValue.ToString())
              .GetCustomAttribute&lt;T&gt;();
      }
  </code></pre>
  
  <p>I call GetAttribute to get the string from my enum. I am using this while displaying data, Instead of displaying the enum as a string, I am displaying the string from the Description Annotation Name.</p>
  
  <p>I am able to write a converter for Windows 8.1 which can take the enum value and give me the description in the annotation Display. However I am unable to achieve the same behavior in Windows Phone 8.1.</p>
  
  <p>In Windows 8.1, the following namespace will help me</p>
  
  <pre><code>using System.ComponentModel.DataAnnotations;
  </code></pre>
  
  <p>However since it is not there in Windows Phone 8.1. How do I achieve a similar behavior? Is there a workaround?</p>