i'm currently programming an uwp app and need some help with xaml binding.
Let's say i have 3 Textblocks (textBlock1, textBlock2, textBlock3) and in the code-behind-file 3 string-properties (Text1, Text2, Text3). The Text-properties from the control are binded to the string-properties:
<TextBlock x:Name="textBlock1" Text="{x:Bind Text1, Mode=OneWay}"/>
<TextBlock x:Name="textBlock2" Text="{x:Bind Text2, Mode=OneWay}"/>
<TextBlock x:Name="textBlock3" Text="{x:Bind Text3, Mode=OneWay}"/>
The string-properties are computed properties and their value changes according to the current culture.
public string Text1 => _resource.GetStringResource("text1");
public string Text2 => _resource.GetStringResource("text2");
public string Text3 => _resource.GetStringResource("text3");
If i receive the event, that the culture was changed, i would like to update the ui.
I did find 3 solutions to solve this problem, but i don't like them, thus asking for advice.
Solution 1:
I can call OnPropertyChanged for every string-property. I don't like this because I must do it for every property.
Solution 2:
My second solution would be to use/misuse a ValueConverter like this.
<TextBlock Text="{x:Bind _resource, Converter={StaticResource ResourceToStringConverter}, ConverterParameter=Text1}"/>
and in the converter to call and return _resource.GetStringResource("converterParameter").
I don't really know why i don't like it, but it feels like im misusing the Converter.
Solution 3:
Call this.Binding.Update(). I prefer solution 1 over this.
Thanks in advance.