I finally found the answer. The answer was a confusion between @Shawn Kendrot and another question I asked here: IValueConverter does not start in some scenarios
To summarize the solution for using IValueConverter , I need to link my control to the following estate:
<phone:PhoneApplicationPage.Resources> <Helpers:StaticTextConverter x:Name="TextConverter" /> </phone:PhoneApplicationPage.Resources> <TextBlock Text="{Binding Converter={StaticResource TextConverter}, ConverterParameter=M62}" />
Since the text identifier is passed with the converter parameter, the converter looks almost the same:
public class StaticTextConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter != null && parameter is string) { return App.StaticTexts.Items.SingleOrDefault(t => t.Name.Equals(parameter)).Content; } return null; } }
However, as it turned out, the binding and, therefore, the converter is not called if it does not have a DataContext . To solve this problem, the DataContext property of the control simply needs to be set to something arbitrary:
<TextBlock DataContext="arbitrary" Text="{Binding Converter={StaticResource TextConverter}, ConverterParameter=M62}" />
And then everything works as intended!
source share