title: Can a TypeConverter be used for constructor argument
body: <p>I'm trying to write a markupextension like this:</p>
  
  <pre><code>[MarkupExtensionReturnType(typeof(Length))]
  public class LengthExtension : MarkupExtension
  {
      // adding the attribute like this compiles but does nothing.
      public LengthExtension([TypeConverter(typeof(LengthTypeConverter))]Length value)
      {
          this.Value = value;
      }
  
      [ConstructorArgument("value")]
      public Length Value { get; set; }
  
      public override object ProvideValue(IServiceProvider serviceProvider)
      {
          return this.Value;
      }
  }
  </code></pre>
  
  <p>To be used like this:</p>
  
  <pre><code>&lt;Label Content="{units:Length 1 mm}" /&gt;
  </code></pre>
  
  <p>Errs with:</p>
  
  <blockquote>
    <p>The TypeConverter for type "Length" does not support converting from string.</p>
  </blockquote>
  
  <p>The TypeConverter works if I:</p>
  
  <ul>
  <li>Put it on the <code>Value</code>property and have a default ctor.</li>
  <li>Decorate the <code>Length</code> type with the attribute.</li>
  </ul>
  
  <p>While this may be x/y I don't want any of those solutions.</p>
  
  <p>Here is the code for the converter:</p>
  
  <pre><code>public class LengthTypeConverter : TypeConverter
  {
      public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
      {
          if (sourceType == typeof(string))
          {
              return true;
          }
  
          return base.CanConvertFrom(context, sourceType);
      }
  
      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
      {
          if (destinationType == typeof(InstanceDescriptor) || destinationType == typeof(string))
          {
              return true;
          }
  
          return base.CanConvertTo(context, destinationType);
      }
  
      public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
      {
          var text = value as string;
          if (text != null)
          {
              return Length.Parse(text, culture);
          }
  
          return base.ConvertFrom(context, culture, value);
      }
  
      public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
      {
          if (value is Length &amp;&amp; destinationType != null)
          {
              var length = (Length)value;
              if (destinationType == typeof(string))
              {
                  return length.ToString(culture);
              }
              else if (destinationType == typeof(InstanceDescriptor))
              {
                  var factoryMethod = typeof(Length).GetMethod(nameof(Length.FromMetres), BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(double) }, null);
                  if (factoryMethod != null)
                  {
                      var args = new object[] { length.metres };
                      return new InstanceDescriptor(factoryMethod, args);
                  }
              }
          }
  
          return base.ConvertTo(context, culture, value, destinationType);
      }
  }
  </code></pre>