title: WPF Value Converter to replace error code with localized string
body: <p>I have a viewmodel implementing the IDataErrorInfo interface for validation, for an error it produces a string which is a key in the resource dictionary for a localized string describing the error. However when trying to apply the following style and template to the textbox I get the red border but no tooltip, however removing my converter and using the default one gives me the tooltip but obviously not the localized string.</p>
  
  <p>Can you see what I am doing wrong and/or if there is a better way of doing this?</p>
  
  <pre><code>class MessageCodeToMessageConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          if (value != null)
          {
              string messageCode = (string)value;
              try
              {
                  return (string)App.Current.Resources[messageCode];
              }
              catch (Exception)
              {
                  return messageCode;
              }
          }
          else
          {
              return null;
          }
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          return "";
      }
  }
  
          &lt;local:MessageCodeToMessageConverter x:Key="Converter"&gt;&lt;/local:MessageCodeToMessageConverter&gt;
          &lt;Style x:Key="TextBox" TargetType="TextBox"&gt;
              &lt;Style.Triggers&gt;
                  &lt;Trigger Property="Validation.HasError" Value="true"&gt;
                      &lt;Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent, Converter={StaticResource Converter}}"/&gt;
                  &lt;/Trigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
          &lt;ControlTemplate x:Key="ErrorTemplate"&gt;
              &lt;DockPanel LastChildFill="True"&gt;
                  &lt;Border BorderBrush="Red" BorderThickness="1"&gt;
                      &lt;AdornedElementPlaceholder /&gt;
                  &lt;/Border&gt;
              &lt;/DockPanel&gt;
          &lt;/ControlTemplate&gt;
  </code></pre>