title: Why is the multibinding always passing DependencyProperty.UnsetValue for the first value?
body: <p>In a form in my WPF application, I am building a psuedo bar graph.  The bar graph consists of a Grid with 12 columns.  Each column contains a Rectangle.  I am using databinding to bind the height of the rectangle to the data that I want to graph.  The xaml looks like this:</p>
  
  <pre><code>&lt;Border BorderBrush="{DynamicResource ControlBorder}"
          BorderThickness="2"
          Grid.Column="1"
          Grid.Row="0"
          Margin="0,5"
          Name="SNRGraphBorder"&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Rectangle Fill="{DynamicResource TextForeground}"
                     Grid.Column="0"
                     Margin="1,5,2,0"
                     Name="Data01"
                     VerticalAlignment="Bottom"&gt;
              &lt;Rectangle.Height&gt;
                  &lt;MultiBinding Converter="{StaticResource ScaleData}"&gt;
                      &lt;Binding Source="{StaticResource XmlProvider}"
                               XPath="a:PathToData}" /&gt;
                      &lt;Binding Path="RectangleHeight"
                               RelativeSource="{RelativeSource AncestorType={x:Type cs:MyControl}}" /&gt;
                  &lt;/MultiBinding&gt;
              &lt;/Rectangle.Height&gt;
          &lt;/Rectangle&gt;
          . . .
      &lt;/Grid&gt;
  &lt;/Border&gt;
  </code></pre>
  
  <p>I've only included one rectangle for brevity.</p>
  
  <p>Here's the code for the IMultiValueConverter used in the MultiBinding:</p>
  
  <pre><code>public class ScaleDataConverter : IMultiValueConverter {
  
      public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
          double snr = 0.0;
  
          if ( values[ 0 ] is string ) {
              snr = double.Parse( values[ 0 ] as string );
  
          } else if ( values[ 0 ] is int || values[ 0 ] is double || values[ 0 ] is long || values[ 0 ] is float ) {
              snr = (double) values[ 0 ];
          } else {
              return values[ 0 ];
          }
  
          double ActualHeight = (double) values[ 1 ];
          return snr * ActualHeight / 99.0;
      }
  
      public object[] ConvertBack( object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture ) {
          throw new NotImplementedException();
      }
  
  }
  </code></pre>
  
  <p>Finally, here's the code behind for this control:</p>
  
  <pre><code>public partial class MyControl : UserControl {
  
      public XmlDataProvider DataProvider { get; set; }
  
      public DeviceMonitor DeviceMonitor { get; set; }
  
      public double RectangleHeight {
          get { return SNRGraphBorder.ActualHeight; }
      }
  
      public MyControl() {
          InitializeComponent();
          DataProvider = Resources[ "XmlProvider" ] as XmlDataProvider; 
      }
  
      private void GetDiagnosticsInfo() {
          if ( DeviceMonitor != null ) {
              XmlDocument diagnosticsDoc = new XmlDocument();
              string info = DeviceMonitor.GetDiagnosticInfo();
              diagnosticsDoc.LoadXml( info );
              DataProvider.Document = diagnosticsDoc;
          }
      }
  
      private void RefreshButton_Click( object sender, RoutedEventArgs e ) {
          GetDiagnosticsInfo();
          e.Handled = true;
      }
  }
  </code></pre>
  
  <p>I've put breakpoints into the converter on the <code>if ( values[ 0 ] is string )</code> line.  I see that the first entry in the values array is always DependencyProperty.UnsetValue.  Yet I know that the XML has other data for this property.  What am I doing wrong?</p>
  
  <p>Thanks</p>
  
  <p>Tony</p>