title: MultiBinding with binding StringFormat
body: <p>I am trying to display some label with MultiBinding with Binding on StringFormat.</p>
  
  <p>Like that:</p>
  
  <pre><code>&lt;Label.Content&gt;
      &lt;TextBlock&gt;
          &lt;TextBlock.Text&gt;
              &lt;MultiBinding StringFormat="{Binding LabelStringFormat, Source={DynamicResource Texts}}"&gt;
                  &lt;Binding Path="Lib1" /&gt;
                  &lt;Binding Path="Lib2" /&gt;
              &lt;/MultiBinding&gt;
          &lt;/TextBlock.Text&gt;
      &lt;/TextBlock&gt;
  &lt;/Label.Content&gt;
  </code></pre>
  
  <p>LabelStringFormat can be something like "[{0}/{1}]" or something like that. It is known in build but must be used from Resource.</p>
  
  <p>But when I use something like code above, I get error:</p>
  
  <pre><code>A 'Binding' cannot be set on the 'StringFormat' property of type 'MultiBinding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
  </code></pre>
  
  <p>I can use binding on Content and create string in ViewModel, but it is unnoticed when there is more labels like this one.</p>
  
  <p>Thanks
  Jakub</p>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>Use Convertor:</p>
  
  <pre><code>public class StringMultiValueConverter : IMultiValueConverter
  {
      public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          return string.Format(values.Last() as string, values);
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>In WPF add convertor to Resources:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;myComponents:StringMultiValueConverter x:Key="stringMultiValueConverter"/&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>In Label add:</p>
  
  <pre><code>&lt;Label.Content&gt;
      &lt;TextBlock&gt;
          &lt;TextBlock.Text&gt;
              &lt;MultiBinding Converter="{StaticResource stringMultiValueConverter}"&gt;
                  &lt;Binding Path="Lib1" /&gt;
                  &lt;Binding Path="Lib2" /&gt;
                  &lt;Binding Path="LabelStringFormat" Source="{Dynamic Texts}"/&gt;
              &lt;/MultiBinding&gt;
          &lt;/TextBlock.Text&gt;
      &lt;/TextBlock&gt;
  &lt;/Label.Content&gt;
  </code></pre>
  
  <p>This work when string format is last param of Multibinding.</p>