views:

38

answers:

1

In normal Silverlight projects, localization in the xaml view is done using:

Text="{BindingPath=ApplicationStrings.MyNewString, Source={StaticResource ResourceWrapper}}"

My question is : how to do correct localization from labels when using the MVVM pattern?

Is this done like described here ?

In xaml view:

Text="{Binding LblUsername,FallbackValue='User Name'}"

And the LoginViewModel.cs class:

public string LblUsername
{
    get { return Resources.Username; }
}

Any tips here ?


And how about reusing the same string on multiple view/viewmodels ? (Just imagine that I need 'Username' on multiple views.) Does it make sense to to derive all viewmodels from a basemodel which defines all resources ?

A: 

Well we use the

ApplicationStrings.MyNewString, Source={StaticResource ResourceWrapper}}

And it works fine. it's a project on the solution level and i just ref. the project into the individual projects, then i can use it as a global localization. and one "label" is only defined once.

I'm Danish so we have german, swedish, danish, english etc. translations running. If this dont help you i can provide code. But you are on the right track with option one :-)

ReLoad