Reputation: 25597
I have a localization markup extension method for strings, which I can apply in this way:
<TextBlock Text="{l:Translate 'My string'}" />
How can I apply this markup extension method to the result of a binding? I.e. something like that:
<TextBlock Text="{l:Translate '{Binding Path=myStringParameter}'}" />
Upvotes: 4
Views: 1549
Reputation: 13022
With a markup extention just do this:
{l:Translate {Binding Path=myStringParameter}}
The XAML parser will handle the inner markup extention itself. Like in classical WPF: {StaticResource {x:Type Button}}
Upvotes: 1
Reputation: 1057
I believe it is not possible the way you do it, but you can rewrite its as follows:
<TextBlock>
<TextBlock.Text>
<l:Translate>
<Binding Path="myStringParameter" />
</l:Translate>
</TextBlock.Text>
</TextBlock>
Upvotes: 1