如何将字符串值从资源文件传递到 ConverterParameter?
How to pass a string value from resource file to a ConverterParameter?
我想传递这个资源,在代码中看起来像这样:
AppResources.lbCountry;
此处为ConverterParameter
:
<Label Text="{Binding SelectedCountry.Name, Converter={StaticResource nullToResourceConv}, ConverterParameter={--}}" >
编辑
lbCountry
在 AppResources
:
internal static string lbCountry {
get {
return ResourceManager.GetString("lbCountry", resourceCulture);
}
}
Resx
命名空间定义:
xmlns:Resx="clr-namespace:XamApp.Resources"
但这不起作用:
ConverterParameter={x:Static Resx:AppResources.lbCountry}}
错误:
x:Static: unable to find a public static field, static property,
const or enum value named lbCountry in Resx:AppResources
试试这个:
ConverterParameter={x:Static myNameSpace:AppResources.lbCountry}
还要确保 属性 是 public
我想传递这个资源,在代码中看起来像这样:
AppResources.lbCountry;
此处为ConverterParameter
:
<Label Text="{Binding SelectedCountry.Name, Converter={StaticResource nullToResourceConv}, ConverterParameter={--}}" >
编辑
lbCountry
在 AppResources
:
internal static string lbCountry {
get {
return ResourceManager.GetString("lbCountry", resourceCulture);
}
}
Resx
命名空间定义:
xmlns:Resx="clr-namespace:XamApp.Resources"
但这不起作用:
ConverterParameter={x:Static Resx:AppResources.lbCountry}}
错误:
x:Static: unable to find a public static field, static property, const or enum value named lbCountry in Resx:AppResources
试试这个:
ConverterParameter={x:Static myNameSpace:AppResources.lbCountry}
还要确保 属性 是 public