title: How to dynamically change ConverterParameter (or any) property of a MultiBinding (or any other) resource at runtime?
body: <p>i'm new to wpf and xaml. i find solutions of most of the problems (in other languages) by searching here n there or googling around but this one made me crazy. i searched a lot on google and browsed many forums, but it seems that this time i met with a real challenge!</p>
  
  <p>I have following code in Window.Resources:</p>
  
  <pre><code>&lt;my:NameConverter x:Key="NameConverter"/&gt;
  
  &lt;MultiBinding x:Key="CustomerFullNameBinding" 
                Converter="{StaticResource NameConverter}"
                ConverterParameter="LastNameFirst"&gt;
       &lt;Binding Path="FirstName"  /&gt;
       &lt;Binding Path="MiddleName" /&gt;
       &lt;Binding Path="LastName" /&gt;
  &lt;/MultiBinding&gt;
  </code></pre>
  
  <p>The <strong>NameConverter</strong> class returns full name by combining individual parts of the name. The return value is based on value of <strong>ConverterParameter</strong> which can be one of the following: <em>FirstNameFirst, LastNameFirst, OnlyFirstName, OnlyLastName, Initials</em> (there are a few more; but for simplicity, let's not consider them)</p>
  
  <p>This code works fine. I use following to get the result:</p>
  
  <pre><code>&lt;TextBlock Text="{DynamicResource CustomerFullNameBinding}"/&gt;
  </code></pre>
  
  <p>However, the problem is that if i use the resource <strong>CustomerFullNameBinding</strong> 20 times in my code (like shown abovw) all of them would show the name in ONE particular format. (i.e. Here in the declaration of CustomerFullNameBinding i have set <em>ConverterParameter="LastNameFirst"</em> so all 20 references will show name in that way only.)</p>
  
  <p><strong>Now my question is can i make it more "generalized" so that the i can set the value of <em>ConverterParameter</em> dynamically?</strong> i.e. i can have multiple textblocks that can display full name in different formats. I know it is possible if we create multiple resources like follows:</p>
  
  <pre><code> &lt;MultiBinding x:Key="CustomerFullNameBinding_FirstNameFirst" 
                 Converter="..." ConverterParameter="FirstNameFirst"&gt;
        ......
   &lt;/MultiBinding&gt;
   &lt;MultiBinding x:Key="CustomerFullNameBinding_LastNameFirst" 
                 Converter="..." ConverterParameter="LastNameFirst"&gt;
        ......
   &lt;/MultiBinding&gt;
   &lt;MultiBinding x:Key="CustomerFullNameBinding_OnlyFirstName" 
                 Converter="..." ConverterParameter="OnlyFirstName"&gt;
        ......
   &lt;/MultiBinding&gt;
  
   ... and so on ...
  </code></pre>
  
  <p>But i dont want that, 'coz it'll really make my code too bulky, and most importantly it'll void concept of reusability of resources!</p>
  
  <p>Please suggest me any possible solution. <br />
  Thanks in advance.</p>
  
  <p><strong>Note:</strong> I got the original idea from <a href="http://msdn.microsoft.com/en-us/library/ms752275.aspx" rel="nofollow noreferrer">here</a>. The similar working example can be found msdn.microsoft.com/en-us/library/ms771336.aspx.</p>
  
  <p>Tags: wpf xaml staticresource dynamicresource binding</p>