Per page/per view Culture #15212
-
Hi All, I've recently come across a requirement to have a specific page or set of views using a different culture to the main app. What I'd like to do is to change the culture (specifically currency formatting) without affecting the global culture. Is there a way to do this in Xamarin.Forms? I've worked around this by doing the formatting in the viewmodel and exposing this to the UI as bindable string properties, but since I also need to use the value itself for view logic it means I've got 2 properties containing the same data in different formats, which isn't brilliant. I'd much rather make use of Binding.StringFormat to take care of currency formatting, but I don't know of any way to do this without changing the culture for the entire app. I'd appreciate any insights or pointers into how I might accomplish this, if it is at all possible. Thanks! EDIT I'm also interested in whether there would be any difference in acheiving this between Xamarin.Forms and MAUI. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Coming back to this after seeing #11815 and it got me wondering if we could set the culture per binding expression, something like
to find a built-in culture with the given specifier (in this case, British English) and use it to format Value as currency would be quite nice, or
to allow the use of a custom culture. Leaving the property unset obviously uses CurrentUICulture. |
Beta Was this translation helpful? Give feedback.
-
Huh, turns out there are already tickets open for this feature in X.F and Maui repos: dotnet/maui#5696. I guess I can get some sense of validation that they are suggesting the exact same usage as I have here, so that's something. |
Beta Was this translation helpful? Give feedback.
Huh, turns out there are already tickets open for this feature in X.F and Maui repos: dotnet/maui#5696. I guess I can get some sense of validation that they are suggesting the exact same usage as I have here, so that's something.