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 735477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:29:40+00:00 2026-05-14T07:29:40+00:00

I am attempting to write a multilingual application in Silverlight 4.0 and I at

  • 0

I am attempting to write a multilingual application in Silverlight 4.0 and I at the point where I can start replacing my static text with dynamic text from a SampleData xaml file. Here is what I have:

My Database

<SampleData:something xmlns:SampleData="clr-namespace:Expression.Blend.SampleData.MyDatabase" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <SampleData:something.mysystemCollection>
    <SampleData:mysystem ID="1" English="Menu" German="Menü" French="Menu" Spanish="Menú" Swedish="Meny" Italian="Menu" Dutch="Menu" />
  </SampleData:something.mysystemCollection>
</SampleData:something>

My UserControl

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="Something.MyUC" d:DesignWidth="1000" d:DesignHeight="600">
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource MyDatabase}}">
        <Grid Height="50" Margin="8,20,8,0" VerticalAlignment="Top" d:DataContext="{Binding mysystemCollection[1]}" x:Name="gTitle">
            <TextBlock x:Name="Title" Text="{Binding English}" TextWrapping="Wrap" Foreground="#FF00A33D" TextAlignment="Center" FontSize="22"/>
        </Grid>
    </Grid>
</UserControl>

As you can see, I have 7 languages that I want to deal with. Right now this loads the English version of my text just fine. I have spent the better part of today trying to figure out how to change the binding in my code to swap this out when I needed (lets say when I change the language via drop down).

  • 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-14T07:29:41+00:00Added an answer on May 14, 2026 at 7:29 am

    You are going about this the wrong way. Best practice for localization in Silverlight is to use resource files holding the translated keywords. Here is some more info about this:

    http://msdn.microsoft.com/en-us/library/cc838238%28VS.95%29.aspx

    EDIT:

    Here is an example where I use a helper class to hold the translated strings. These translations could then be loaded from just about anywhere. Static resource files, xml, database or whatever. I made this in a hurry, so it is not very stable. And it only switches between english and swedish.

    XAML:

    <UserControl x:Class="SilverlightApplication13.MainPage"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:local="clr-namespace:SilverlightApplication13"
                 mc:Ignorable="d"
                 d:DesignWidth="640"
                 d:DesignHeight="480">
    
        <UserControl.Resources>
            <local:TranslationHelper x:Key="TranslationHelper"></local:TranslationHelper>
        </UserControl.Resources>
    
        <Grid x:Name="LayoutRoot">
            <StackPanel>
    
                <TextBlock Margin="10"
                           Text="{Binding Home, Source={StaticResource TranslationHelper}}"></TextBlock>
    
                <TextBlock Margin="10"
                           Text="{Binding Contact, Source={StaticResource TranslationHelper}}"></TextBlock>
    
                <TextBlock Margin="10"
                           Text="{Binding Links, Source={StaticResource TranslationHelper}}"></TextBlock>
    
                <Button Content="English"
                        HorizontalAlignment="Left"
                        Click="BtnEnglish_Click"
                        Margin="10"></Button>
    
                <Button Content="Swedish"
                        HorizontalAlignment="Left"
                        Click="BtnSwedish_Click"
                        Margin="10"></Button>
            </StackPanel>
        </Grid>
    </UserControl>
    

    Code-behind + TranslationHelper class:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Windows.Threading;
    using System.ComponentModel;
    
    namespace SilverlightApplication13
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
    
                //Default
                (this.Resources["TranslationHelper"] as TranslationHelper).SetLanguage("en-US");
            }
    
            private void BtnEnglish_Click(object sender, RoutedEventArgs e)
            {
                (this.Resources["TranslationHelper"] as TranslationHelper).SetLanguage("en-US");
            }
    
            private void BtnSwedish_Click(object sender, RoutedEventArgs e)
            {
                (this.Resources["TranslationHelper"] as TranslationHelper).SetLanguage("sv-SE");
            }
        }
    
        public class TranslationHelper : INotifyPropertyChanged
        {
            private string _Contact;
    
            /// <summary>
            /// Contact Property
            /// </summary>
            public string Contact
            {
                get { return _Contact; }
                set
                {
                    _Contact = value;
                    OnPropertyChanged("Contact");
                }
            }
    
            private string _Links;
    
            /// <summary>
            /// Links Property
            /// </summary>
            public string Links
            {
                get { return _Links; }
                set
                {
                    _Links = value;
                    OnPropertyChanged("Links");
                }
            }
    
            private string _Home;
    
            /// <summary>
            /// Home Property
            /// </summary>
            public string Home
            {
                get { return _Home; }
                set
                {
                    _Home = value;
                    OnPropertyChanged("Home");
                }
            }
    
    
    
            public TranslationHelper()
            {
                //Default
                SetLanguage("en-US");
            }
    
            public void SetLanguage(string cultureName)
            {
                //Hard coded values, need to be loaded from db or elsewhere
    
                switch (cultureName)
                {
                    case "sv-SE":
                        Contact = "Kontakt";
                        Links = "Länkar";
                        Home = "Hem";
                        break;
    
                    case "en-US":
                        Contact = "Contact";
                        Links = "Links";
                        Home = "Home";
                        break;
    
                    default:
                        break;
                }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            protected virtual void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to write the results from an SQL query into text files.
I am attempting to write a script that can retrieve the HTML from my
I'm attempting to write an application to extract properties and code from proprietary IDE
I am attempting to write an application in which I have two text fields
I'm attempting to write a shader to put a border around text. It compiles
I have been attempting to write a VBA Script that can parse out other
I'm attempting to write my own Log4Net Glimpse plugin (so I can interface with
I am attempting to write some JUnit tests for my android application. The application
I am attempting to write some Java code that takes an image from a
I'm attempting to write an ASCII null character (nul) to a file from a

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.