views:

255

answers:

2

Hey everyone,

I´m using a markupextension for loading internationalized strings in a WPF application like this:

<Button Content="{Translate MyText}"/>

My markupextension is named "TranslateExtension" and it searches a value for the key "MyText" from a database. It does this in the

ProvideValue(IServiceProvider serviceProvider)

method which returns the right string. Everything is working fine.

My problem is, that the ProvideValue-Method isn´t ever called again and there´s no way to pull a new string from the database when the language is changed. I now need a way to make the returned value "dynamic", to make the Button to reload it´s xaml and re-use the markupextension whether it´ll be through an event thrown when changing languages or whatever. How do i make the system call the ProvideValue-Method again? I tried the likes of InvalidateVisual() InvalidateArrange() InvalidateMeasure() UpdateLayout()...

I hope I made myself clear. Please feel free to ask for more information of you think you´re able to provide ideas or solutions. Thank you

A: 

I don't have an answer for you, but rather a suggestion...

Perhaps you could consider using a Binding combined with an IValueConverter to do the translation. Then, if the language of the user interface changes, you can simply recurse all bindings and refresh them.

Like I said, just an idea.

Mark
Hello Mark,thank you for your suggestion. I´ll have a look into using bindings but they might not work in my case. the whole thing is a bit more difficult and i simplified what i needed. thing is, i´m making the languages chosable for every form separately and if the form doesn´t have a chosen language it´s going to rely on the standard language (which also can be changed).I found out, that the markup extensions are exposed after the xaml gets rendered (except when there´s still a reference somewhere). I´m currently trying bubble and tunnel events and registering a handler on the form.
but i´ll have to evaluate performance and memory issues.anyway, it seems like there isn´t an "really reload the form"-method anywhere near.
A: 

Did you get any solution to this problem ? if yes please post it...

k0v1d