When I put localized text in my annotations, and the user selects a different language while the chart is showing, do I have to rebuild my annotations?
I had hoped that I could register ‘globalized’ texts in my annotation object, and localize them in the getter method, but it seems that the getter method is not called every time the annotation text is displayed in a ToolTip
- You must login to post comments
This is a great problem for MVVM Annotations API to solve
If your annotations are generated using our MVVM API, then the BaseAnnotationViewModel.Text
or BaseAnnotationViewModel.Tooltip
properties can be bound to keys and using a converter, can localise the string.
for example, given an annotation declared like this:
<Annotation Tooltip={Binding Path=TooltipKey, Converter={StaticResource LocalisationConverter}}/>
- TooltipKey is a key which contains what message to display + language
- Localisation converter is a custom converter you’ve created to lookup the key and turn it into a string for the user
e.g. if you have TooltipKey = “Warning_Eng” then the converter returns ‘Warning this is bad”
but if TooltipKey = “Warning_Fr” then the converter returns “attention, c’est mauvais!”
How to inject the converter into the binding if you’re using our MVVM API? That part’s going to require an example (which will take our team a while to create)
let me know if this is helpful so far
Best regards
Andrew
- Andrew Burnett-Thompson answered 1 year ago
- last edited 1 year ago
- You must login to post comments
@Andrew
My AnnotationViewModel does inherit from BaseAnnotationViewModel, and the getter method for the tooltip text implements the localization. All I was missing was to invoke OnPropertyChanged on the annotations collection when the user switches locale.
Your solution based on a converter is probably more elegant though.
- Søren Bech Christensen answered 1 year ago
- last edited 1 year ago
- Of course! OnPropertyChanged will do it. Converters are nice but to inject a style into the binding between Annotation and AnnotationViewModel would require overriding styles. Have you got a solution now?
- Yes, I’m good for now :-)
- You must login to post comments
Please login first to submit.