Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 514031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:28:57+00:00 2026-05-13T07:28:57+00:00

I have a small WPF application that I am working on localizing. I have

  • 0

I have a small WPF application that I am working on localizing. I have read thru a number of documents but I have not found a good source of information about dealing with ‘rich’ content – for example:

I have a ui element (TextBlock) that contains a mix of text with formatting, inline images and symbols. I want to localize this element. I believe to localize this element in a way that is natural in another language that the position of the formulas/symbols will need to shift in relation to the surrounding text – and that the best formatting for the text may be slightly different in other languages as well.

I am looking for suggestions, resources and/or approaches for localizing ‘rich’ content (content that mixes text, formatting and inline ui elements) in XAML/WPF. Given the emphasis on composition and ‘rich’ UI in WPF I was surprised not to find any information on the scenario above – what am I missing?

I have thought about storing XAML in the resource file and then parsing it at runtime for inclusion in the UI and about creating a view/usercontrol that is swapped out based on locale – but I am not seeing any mention of these approaches (which makes me wonder if I am on the ‘wrong track’) and am hoping someone has experience or information to share?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:28:58+00:00Added an answer on May 13, 2026 at 7:28 am

    The StaticResource markup extension works very well for what you are trying to accomplish. You can include almost anything using a StaticResource, even when a DynamicResource doesn’t work:

    <Window ...>
      <Window.Resources>
    
        <Span x:Key="Whatever">
          <Bold>Hello</Bold> there<LineBreak/>
          A green circle:
          <InlineUIContainer>
            <Ellipse Width="10" Height="10" Fill="Green" />
          </InlineUIContainer>
        </Inline>
    
      </Window.Resources>
    
      ...
      <TextBlock>
        <StaticResource ResourceKey="Whatever" />
      </TextBlock>
    

    Now localizing this is easy:

    1. Move the Span resource into a separate ResourceDictionary and merge into your Application’s resource dictionary.
    2. During application startup and before any windows are created, use code to get the current culture and add an additional language-specific ResourceDictionary to application.Resources.MergedDictionaries. The satellite dictionary can be loaded using WPF’s built-in localization mechanism.

    As long as the dictionares are merged into the application dictionary in the correct order, any named resource that is found in the localized dictioary will take precendence over the one in the main dictionary, for example your Spanish localization dll could have a xaml file containing this:

    <ResourceDictionary>
      <Span x:Key="Whatever">
        El círculo rojo
          <InlineUIContainer>
            <Ellipse Width="10" Height="10" Fill="Red" />
          </InlineUIContainer>
        dice <Bold>hola!</Bold>
      </Span>
    </ResourceDictionary>
    

    Note that the message is similar, but for Spanish the circle is red and the layout of the text is different.

    You can take this much further with ControlTemplates if you want to. Using ControlTemplates will allow you to do such things as have buttons laid out in a different order depending on the locale. For example if your generic dictionary contains:

    <ResourceDictionary>
      <ControlTempate x:Key="Something" TargetType="ContentControl">
        <StackPanel>
          <TextBlock Text="In English we want the text above the button" />
          <ContentPresenter />
        </StackPanel>
      </ControlTemplate>
    </ResourceDictionary>
    

    You can add this to your window or user control:

    <ContentControl Template="{StaticResource Something}">
      <Button Command="Save">Save File</Button>
    </ContentControl>
    

    And then you change the layout for another language, for example:

    <ResourceDictionary>
      <ControlTempate x:Key="Something" TargetType="ContentControl">
        <DockPanel>
          <ContentPresenter DockPanel.Dock="Left" />
          <TextBlock Text="En español en el botón a la izquierda del texto" />
            <!-- In spanish the button is to the left of the text -->
        </DockPanel>
      </ControlTemplate>
    </ResourceDictionary>
    

    Note: If you only use localization in DependencyProperties (eg no InlineCollections, etc) you can get away with using {DynamicResource} which allows the locale to change at any time with an instant update of the UI. To do this with my first example, instead of including a <Span> in the ResourceDictionary and including it inside a TextBlock, you can put the TextBlock in a ControlTemplate inside the ResourceDictionary.

    This is only the beginning of the flexibility of localization with WPF. You can go much further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.