使用带有WPF Localization Extension的转换器

时间:2012-02-07 12:41:55

标签: wpf localization converter

我想在翻译的内容上使用自定义转换器,例如我现在有:

Content="{lex:LocText Library:Language:Overview}"

但我想添加一个转换器( IValueConverter )(就像你可以用 Binding )。怎么做到这一点?这个插件的文档有点'空'。

2 个答案:

答案 0 :(得分:1)

WPF Localization Extension 2.1现在支持一系列新的可能性,包括您的需求。

http://wpflocalizeextension.codeplex.com/

答案 1 :(得分:0)

为什么不绑定到“经典”.resx资源文件呢? 这在WPF中非常简单。只需创建资源文件并显示如下文本:

...
<GridViewColumn Header="{x:Static Properties:Strings.UserName}" DisplayMemberBinding="{Binding UserName}"/>
...

此处Header在“Properties”命名空间中的Strings.resx中查找“UserName”。 属性名称空间别名的定义如下:

<Window x:Class="MyControls.MyWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pwc="clr-namespace:PostalWpfControls"
        xmlns:Properties="clr-namespace:MyWpfControls.Properties"
...