Support for x:Shared property for localization
Posted: 20 May 2022, 12:21
Hi,
tl;dr: Are there any plans for implementing support for the x:Shared property in Noesis? Or some alternative way to achieve the same thing?
I'm experimenting with how we are going to solve localization and text formatting in our UIs. My first thought was to create resource dictionaries with a resource for each localization key. However, since we need the text to be formatted with boldness, colors, text icons etc. it will not be enough to simply store string values in the resource dictionaries. We also want to be able to use bindings to properties of the data context in our loc entries. So I tried having each loc entry be a TextBlock, like this:
Then I would use them like this:
The issue is if I want to use the same resource in multiple places, like so:
Then the text only shows up once, because both content controls are literally referring to the same TextBlock instance, rather than instantiating copies of the TextBlock. This is fixed by using the x:Shared property, like so:
This works fine in Blend, but it seems like this property is not supported in Noesis. Are there any plans to implement it? Or do you have ideas on how to work around it in a nice way?
We have only just started experimenting with localization and text formatting in Noesis, so we still have the possibility to go down a different route entirely, but it certainly would be nice if we were able to use static resources in this manner.
tl;dr: Are there any plans for implementing support for the x:Shared property in Noesis? Or some alternative way to achieve the same thing?
I'm experimenting with how we are going to solve localization and text formatting in our UIs. My first thought was to create resource dictionaries with a resource for each localization key. However, since we need the text to be formatted with boldness, colors, text icons etc. it will not be enough to simply store string values in the resource dictionaries. We also want to be able to use bindings to properties of the data context in our loc entries. So I tried having each loc entry be a TextBlock, like this:
Code: Select all
<TextBlock x:Key="LOC@NEW_GAME">New Game</TextBlock>
<TextBlock x:Key="LOC@TEST"><Bold>bold text</Bold> and images <InlineUIContainer><Image Source="{StaticResource paradox_logo}"/></InlineUIContainer></TextBlock>
<TextBlock x:Key="LOC@SETTING_VALUE_PERCENTAGE"><Run Text="{Binding Path=Value, StringFormat=p0}"/></TextBlock>
Code: Select all
<Button Content="{StaticResource LOC@NEW_GAME}"/>
<ContentControl Content="{StaticResource LOC@TEST}"/>
Code: Select all
<ContentControl Content="{StaticResource LOC@TEST}"/>
<ContentControl Content="{StaticResource LOC@TEST}"/>
Code: Select all
<TextBlock x:Key="LOC@NEW_GAME" x:Shared="False">New Game</TextBlock>
We have only just started experimenting with localization and text formatting in Noesis, so we still have the possibility to go down a different route entirely, but it certainly would be nice if we were able to use static resources in this manner.