title: Specify target type for IValueConverter
body: <p>I have a situation where I am using a multi-value converter.  The values passed to it are themselves being converted.</p>
  
  <pre><code>&lt;MenuItem&gt;
      &lt;MenuItem.IsEnabled&gt;
          &lt;MultiBinding Converter="{StaticResource BooleanAndConverter}"&gt;
              &lt;Binding Path="Prop1" Converter="{StaticResource Converter1}" /&gt;
              &lt;Binding Path="Prop2" Converter="{StaticResource Converter1}" /&gt;
          &lt;/MultiBinding&gt;
      &lt;/MenuItem.IsEnabled&gt;
  &lt;/MenuItem
  </code></pre>
  
  <p>Converter1 contains some error checking to confirm that it is called with a valid target type.  It throws an exception if not, as this is a developer error and the situation should be fixed.</p>
  
  <p>The problem is that when Converter1 is used in this context the target type is System.Object.  Now the BooleanAndConverter requires values of a certain type (Boolean), so how can I get that type passed as the target type of Converter1?</p>
  
  <p>As requested here is the BooleanAndConverter code:</p>
  
  <pre><code>    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          foreach (object value in values)
          {
              if (value.GetType() != typeof(bool))
              {
                  throw new ArgumentException("BooleanAndConverter can only be used to convert booleans."); // developer error
              }
          }
  
          if (targetType != typeof(bool))
          {
              throw new ArgumentException("BooleanAndConverter can only convert to a boolean."); // developer error
          }
  
          foreach (object value in values)
          {
              if ((bool)value == false)
              {
                  return false;
              }
          }
          return true;
      }
  </code></pre>
  
  <p>Let me restate the question as there seems to be some confusion.  Converter1 knows what type it can convert from and to.  It throws an exception when called with the wrong types.  In this situation the targetType is not getting specified and an exception is being thrown.  How do I get the targetType specified correctly?  When not used in a multi-binding situation is does always get specified correctly based on what is being converted.</p>