Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gettext in StringFormat #30

Closed
Jogge opened this issue Feb 19, 2019 · 3 comments
Closed

Gettext in StringFormat #30

Jogge opened this issue Feb 19, 2019 · 3 comments

Comments

@Jogge
Copy link

Jogge commented Feb 19, 2019

I would like to use Gettext in StringFormat of a Binding like this:

<TextBlock Text="{Binding Name, StringFormat={wpf:Gettext Name: {0}}}">

@D-Bullock
Copy link

Unfortunately that's a limitation of wpf's xaml. You can look at writing a multibinding wrapper to allow binding to occur (see https://www.codeproject.com/Articles/456589/Bindable-Converter-Parameter for an example)

@robert-j-engdahl
Copy link
Owner

robert-j-engdahl commented Feb 20, 2019

@D-Bullock is absolutely right. But this is a frustrating limitation of XAML.

However, while we cannot change the BindingExtension of WPF to support this, we might be able to do this the other way around.

It might be possible to do something like

<TextBlock Text="{wpf:Gettext Name: {0}, Param0={Binding Name}}"/>

or

<TextBlock Text="{wpf:Gettext Name: {0}, Param0Path=Name}"/>

Both the XGetText.Xaml.ps1 and GettextExtension would need to be updated. And as always, pull-requests are welcome :)

@robert-j-engdahl
Copy link
Owner

This will be done with the GettextStringFormatConverter XAML extension, which is applied to the Converter property of the Binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants