mirror of
https://github.com/ckaczor/Common.Wpf.git
synced 2026-02-16 10:48:30 -05:00
Reorganize files
This commit is contained in:
29
Resource/EnumToResourceConverter.cs
Normal file
29
Resource/EnumToResourceConverter.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Common.Wpf.Resource
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user