Usage

Keys

Keys are entered either directly after the extension name (constructor syntax - not in Silverlight) or using the Key property of the LocExtension class. Both will yield the same result (here with the key named Test):

<Button Content="{lex:Loc Test}" />
<Button Content="{lex:Loc Key=Test}" />

Automatic key retrieval

If the control already got or can get a value for its Name or x:Name property, the key may be neglected, provided, that a key exists that matches one of the following criteria (checked in exactly this order):
  • ControlName_PropertyName
  • ControlName
Using our button example we could imagine the following scenario:

<Button Name="MyButton" Content="{lex:Loc}" />
As no key was provided, the extension will first try to resolve a resource key named MyButton_Content. If this fails, it will then look for a resource key named MyButton. If this fails too, no value will be provided.

The separation character (default is underscore) can be individually set up for each control using the LocalizeDictionary.Separation property.

Previous topic: Our first localized text
Next topic: Multiple assemblies and dictionaries

Last edited Jun 15, 2012 at 1:51 PM by MrCircuit, version 4