Files
Common.Wpf/EnumToResourceConverter.cs
Chris Kaczor a85257af74 Upgrade .NET framework
Add enum to resource converter
Add validation resources and logic
2014-06-14 10:18:50 -04:00

30 lines
864 B
C#

using System;
using System.Globalization;
using System.Resources;
using System.Windows.Data;
namespace Common.Wpf
{
public class EnumToResourceConverter : IValueConverter
{
public ResourceManager ResourceManager { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return string.Empty;
var resourceKey = value.GetType().Name + "_" + value;
var resourceValue = ResourceManager.GetString(resourceKey);
return resourceValue ?? string.Format("EnumToResourceConverter: {0} not found", resourceKey);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}