将转换器与WPF本地化扩展一起使用



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

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

但我想添加一个转换器(IValueConverter)到它(就像您可以使用Binding一样)。如何做到这一点?这个插件的文档有点"空"。

WPF本地化扩展2.1现在支持一系列新的可能性,包括您的需求。

http://wpflocalizeextension.codeplex.com/

为什么不绑定到"classic".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"
...

最新更新