View previous topic :: View next topic |
Author |
Message |
kevinkuebler
Joined: 19 Jan 2015 Posts: 20 Location: United States
|
Posted: Fri Oct 30, 2015 2:31 pm Post subject: How to use ConverterParameter with Resx resource |
|
|
Hi,
Just bought the license for Globalizer Pro and installed the latest version (3.8.1). I've begun converting my application (WPF, .Net 4.5.1) to use the Resx markup extension in the XAML.
I also implemented a simple language switching menu, similar to what you have in your sample project to switch the language at runtime. Awesome feature! But on one screen I ran into an exception when I would do that, and after going back and reading the help on the Resx extension I realized it was due to trying to use it within a Binding. (The initial load of the screen worked fine, only got the exception when changing the language).
The trick is that the binding uses a converter and the converter takes a parameter which ends up getting used as a format string inside the Convert method. So I want the ConverterParameter to be provided by the Resx. Is this possible? I'm having trouble getting it to work based on the example provided for using the <Resx> element for a binding.
Side note: I noticed that the product version shown in the file details on the Infralution.Localization.WPF assembly says 3.2.1, not 3.8.1. Is that expected or do I have the wrong version somehow?
Thanks!
Kevin |
|
Back to top |
|
|
kevinkuebler
Joined: 19 Jan 2015 Posts: 20 Location: United States
|
Posted: Fri Oct 30, 2015 6:00 pm Post subject: |
|
|
I ended up changing this to get rid of the converter and just use the Key property of the <Resx> element to act as the string format, the way it's shown in the sample. I would still be interested in knowing if it's possible to use a resource as the converter parameter in case there's another scenario where a converter needs some text for a reason other than a format string. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Nov 01, 2015 11:04 pm Post subject: |
|
|
You have the right version of the Infralution.Localization.WPF assembly - its just that we don't update the version of that assembly (unless something in it has changed) to avoid breaking customers code that depends on the assembly unnecessarily.
If you want to use dynamic language switching then this can introduce some limitations - especially relating to DataBindings. See the following thread on Code Project:
http://www.codeproject.com/Articles/35159/WPF-Localization-Using-RESX-Files?msg=4191050#xx4191050xx _________________ Infralution Support |
|
Back to top |
|
|
kevinkuebler
Joined: 19 Jan 2015 Posts: 20 Location: United States
|
Posted: Mon Nov 02, 2015 2:23 pm Post subject: |
|
|
Okay, thanks. Yeah I read the article, since it's the only documentation on that feature. Anyway, I just wanted to confirm that there was no way to use the Resx element in the manner I was trying to do. I worked around it by changing my code in this case and will keep that limitation in mind for the future. Thanks! |
|
Back to top |
|
|
|