title: Manipulating Value Converters inside DataTemplate
body: <p>I have a set of data templates I am using for my custom control. It works well, but I want to be able to bind it to data and have values scale based on the min / max of the set. I have created the following value converter:</p>
  
  <pre><code>    public class ScaleValueConverter : IValueConverter
  {
      /// &lt;summary&gt;
      /// The property to use the value of
      /// &lt;/summary&gt;
      public string ValueProperty { get; set; }
  
      /// &lt;summary&gt;
      /// The minimum value to be scaled against. Will become 0%
      /// &lt;/summary&gt;
      public int MinValue { get; set; }
  
      /// &lt;summary&gt;
      /// The maximum value to be scaled against. Will become 100%.
      /// &lt;/summary&gt;
      public int MaxValue { get; set; }
  
  
      #region IValueConverter Members
  
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          var type = value.GetType();
          var property = type.GetProperty(ValueProperty);
  
          if (property == null)
              return 0;
  
          var result = System.Convert.ToDecimal(property.GetValue(value, null));
  
          //TODO: Scale stuff
  
          return result + 100;
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  
      #endregion
  }
  </code></pre>
  
  <p>The aim is to have a generic value converter, and simply supply the binding source object, to the value converter in the XAML, and have it sort things out.</p>
  
  <p>I'm not sure how to do this however, as I am unable to access the value converter I have created from my templated control.</p>
  
  <p>I'm looking for something that would work roughly as follows:</p>
  
  <pre><code>        public override void OnApplyTemplate()
      {
          base.OnApplyTemplate();
  
          //Get Value Converters
          var topScaleValueConverter = GetTemplateChild("TopScaleValueConverter");
          var bottomScaleValueConverter = GetTemplateChild("BottomScaleValueConverter");
  
          //Setup value converter Min / Max / ValueProperty here
      }
  </code></pre>
  
  <p>Ideally they would be parts of my template, and I could extract them as parts, but that doesn't appear to work.</p>
  
  <p>Can anyone point me in the right direction for getting this type of behavior working?</p>
  
  <p>Regards</p>
  
  <p>Tristan</p>
  
  <p>EDIT: I suppose it would be nice to be able to dependency inject them. Does anyone know if this is possible?</p>