1

I have a TextBlock which displays signal frequence (e. g. 10 Hz):

<TextBox Name="Frequency" Text="{Binding Path=Frequency, StringFormat={}{0} Hz}"

Now I want to localize "Hz". Ideally would be to just use DynamicResource as part of String.Format:

<TextBox Name="Frequency" Text="{Binding Path=Frequency, StringFormat={}{0} {DynamicResource Measure/Hz}}"

But it doesn't work. I was also thinking about MultiBinding but looks like there is no easy way to access DynamicResource.

Of cource I can combine Frequence value and Frequence measure in ViewModel and just bind it. But I am curious whether there is a nice UI-only solution.

SiberianGuy
  • 24,674
  • 56
  • 152
  • 266

1 Answers1

0

You could use MultiBinding with StringFormat {]{0} {1} with the second binding bound to the resource that will contain your 'Hz', that can be stored in a resx file or in your xaml as resource of String type.

Set resource string to XAML

Community
  • 1
  • 1
Avram Tudor
  • 1,468
  • 12
  • 18