title: How can I pass a reference to another control as an IValueConverter parameter?
body: <p>I am binding some business objects to a WPF ItemsControl.  They are displayed using a custom IValueConverter implementation used to produce the Geometry for a Path object in the DataTemplate as shown here:</p>
  
  <pre><code>&lt;ItemsControl x:Name="Display" 
                Background="White"
                HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch"
                ItemsSource="{Binding ElementName=ViewPlaneSelector, 
                                      Path=SelectedItem.VisibleElements}" 
             &gt;
      &lt;ItemsControl.Resources&gt;
          &lt;!-- This object is just used to get around the fact that ConverterParameter 
          can't be a binding directly (it's not a DependencyProperty on a DependencyObject --&gt;
          &lt;this:GeometryConverterData 
              x:Key="ConverterParameter2"
              Plane="{Binding ElementName=ViewPlaneSelector, 
                              Path=SelectedItem}" /&gt;
          &lt;DataTemplate DataType="{x:Type o:SlenderMember}"&gt;
              &lt;Path Stroke="Blue" StrokeThickness=".5"
                Data='{Binding Converter={StaticResource SlenderMemberConverter}, 
                              ConverterParameter={StaticResource ConverterParameter2}}'
                ToolTip="{Binding AsString}"&gt;
              &lt;/Path&gt;
          &lt;/DataTemplate&gt;
      &lt;/ItemsControl.Resources&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>Note that the items for the ItemsControl are drawn from the ViewPlaneSelector (a ComboBox) SelectedItem.VisibleElements property.  I need that same ViewPlaneSelector.SelectedItem in the SlenderMemberConverter to figure out how to display this element.  I'm trying to get a reference to it into the converter by creating the intermediate GeometryConverterData object in the Resources section.  This object exists solely to get around the problem of not being able to bind directly to the ConverterParameter property (as mentioned in the comments).  Here is the code for the GeometryDataConverter class:</p>
  
  <pre><code>class GeometryConverterData : FrameworkElement {
      public static readonly DependencyProperty PlaneProperty =
          DependencyProperty.Register("Plane", typeof(ViewPlane), 
              typeof(GeometryConverterData), null, ValidValue);
  
      public static bool ValidValue(object o){
          return true;
      }
  
      public ViewPlane Plane {
          get{
              return GetValue(PlaneProperty) as ViewPlane;
          }set{
              SetValue(PlaneProperty, value);
          }
      }
  }
  </code></pre>
  
  <p>I added the ValidValue function for debugging, to see what this property was getting bound it.  It only and always gets set to null.  I know that the ViewPlaneSelector.SelectedItem isn't always null since the ItemsControl has items, and it's items are drawn from the same property on the same object... so what gives?  How can I get a reference to this ComboBox into my ValueConverter.</p>
  
  <p>Or, alternately, why is what I'm doing silly and overly complicated.  I'm as guilty as many of sometimes getting it into my head that something has to be done a certain way and then killing myself to make it happen when there's a much cleaner and simpler solution.</p>