title: Using placeholders in XAML for WPF Localization Extension
body: <p>I am using WPF Localization Extension in my program. 
  To reduce the ammount of similar resources (like "Length in meters", "Length in Kilometers" and so on) I would like to use placeholders and set them in XAML Code.</p>
  
  <p>I thought about something like this</p>
  
  <p>The value for the resource "UI_Length"
  </p>
  
  <pre><code>Length in {0}
  </code></pre>
  
  <p>In CodeBehind this is quite easy with String.Format</p>
  
  <pre class="lang-cs prettyprint-override"><code>String.Format(
          LocalizeDictionary.Instance.GetLocalizedObject("UI_Length", null, LocalizeDictionary.Instance.Culture).ToString(), 
         "Meters");
  </code></pre>
  
  <p>But how can I add another String or even another resource entry in XAML?</p>
  
  <pre class="lang-cs prettyprint-override"><code>&lt;Label x:Name="Label" Content="{lex:LocText Key=UI_Length}, Meters" HorizontalAlignment="Left" VerticalAlignment="Top"/&gt;
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/questions/29817676/binding-placeholder-from-resource-file-in-wpfop%22/%3E%20%20Is%20this%20even%20possible?%20%20I%20already">Binding placeholder from resource file in WPF</a> it seems to be possible but I am not able to get it running for a label</p>
  
  <p><strong>[Update]</strong></p>
  
  <p>I managed to add two Resource values. 
  The trick was to add a TextBlock in the Label.Content. <a href="https://stackoverflow.com/questions/4399178/stringformat-and-multibinding-with-label">see Link</a></p>
  
  <pre class="lang-cs prettyprint-override"><code>        &lt;Label  Grid.Row="1"&gt;
              &lt;Label.Content&gt;
                  &lt;TextBlock&gt;
                      &lt;TextBlock.Text&gt;
                          &lt;MultiBinding StringFormat="{}{0} [{1}]"&gt;
                              &lt;Binding Source="{lex:LocText Key=UI_Length}" /&gt;
                              &lt;Binding Source="{lex:LocText Key=UI_MeterShort}" /&gt;
                          &lt;/MultiBinding&gt;
                      &lt;/TextBlock.Text&gt;
                  &lt;/TextBlock&gt;
              &lt;/Label.Content&gt;
          &lt;/Label&gt;
  </code></pre>
  
  <p>But I still have a problem here. On Startup this works fine but when I try to switch the language with
  </p>
  
  <pre><code>LocalizeDictionary.Instance.Culture = new CultureInfo("de-DE");
  </code></pre>
  
  <p>I get a "Binding cannot be changed after it has been used." Error.
  Is there a similar way to use severall Resource values and still be able to switch the language during runtime?</p>
  
  <p><strong>[Update 2]</strong></p>
  
  <p>I tried the suggestion from Liero but still have an issue here.</p>
  
  <p>In my MainView I set the DataContext to MainViewModel. The VM has a instance of LocalizedTexts. After changing the Language in the ViewModel I call the RaisePropertiesChanged() but I don't get any output.</p>
  
  <p>The TextBlock is bound to the LengthInMeters</p>
  
  <pre><code>&lt;TextBlock Text="{Binding LocalizedTexsts.LengthInMeters}" /&gt;
  </code></pre>
  
  <p>I am calling the RaisePorpertyChanged after changing the language:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    public void ChangeLanguage(string culture)
      {
           LocalizeDictionary.Instance.Culture = new CultureInfo(culture);
           _localizedTexts.RaisePropertyChanged();
      }
  </code></pre>
  
  <p>LengthInMeters looks like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public string LengthInMeters
  {
      get
      {
          return String.Format(
                     LocalizeDictionary.Instance.GetLocalizedObject(
                         "UI_Length", null,
                         LocalizeDictionary.Instance.Culture).ToString(),
                     LocalizeDictionary.Instance.GetLocalizedObject(
                         "UI_Meters", null,
                         LocalizeDictionary.Instance.Culture).ToString()
                 );
      }
  }
  </code></pre>
  
  <p>But the TextBlock stays empty.</p>