如何为静态资源设置转换器?以下示例显示了我的问题 - 我想将TextBlock
文本转换为大写。
<UserControl x:Class="CoRiMaCorporate.HomeScreen.Controls.Home.ConfigurationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mainResources="clr-namespace:MainSharedResources;assembly=MainSharedResources"
xmlns:converters="clr-namespace:CommonClientLibrary.Converters;assembly=CommonClientLibrary" />
<UserControl.Resource>
<converters:StringToUpperCaseStringConverter x:Key="stringToUpperCaseStringConverter" />
</UserControl.Resource>
<Grid>
…
<TextBlock Text="{x:Static mainResources:Lang.Applications}" />
…
</Grid>
我正在寻找类似的东西:
<TextBlock Text="{Binding Converter=stringToUpperCaseStringConverter, ConverterParameter={x:Static mainResources:Lang.Applications}}" />
答案 0 :(得分:4)
静态属性转到绑定Source,由StaticResource提供的转换器
<TextBlock Text="{Binding Converter={StaticResource stringToUpperCaseStringConverter},
Source={x:Static mainResources:Lang.Applications}}" />