添加一个ApplicationResource
private static readonly ResourceManager resourceManager = new ResourceManager("PubDSPackTransfer.Silverlight.Resources.Resource", Assembly.GetExecutingAssembly());
public string Get(string resource)
{
return resourceManager.GetString(resource, Thread.CurrentThread.CurrentUICulture);
}
public static string GetValue(string resource)
{
return resourceManager.GetString(resource, Thread.CurrentThread.CurrentUICulture);
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var reader = (ApplicationResources)value;
return reader.Get((string)parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
页面引用:
<sl:ApplicationResources x:Key="Localization"/>
绑定方式:
{Binding ConverterParameter=FileState, Converter={StaticResource Localization}, Source={StaticResource Localization}}