title: Set multibinding for a xaml element in code behind
body: <p>I have the following working XAML code that basically binds a couple of properties to calculate the final position of my user control:</p>
  
  <pre><code>&lt;UserControl x:Class="CurvePointControl"
      ....
           &gt;
  &lt;UserControl.Resources&gt;
      &lt;local:VToYConverter x:Key="vToYConverter" /&gt;
  &lt;/UserControl.Resources&gt;
  &lt;UserControl.RenderTransform&gt;
      &lt;TranslateTransform x:Name="XTranslateTransform" &gt;
          &lt;TranslateTransform.Y&gt;
              &lt;MultiBinding Converter="{StaticResource vToYConverter}"&gt;
                  &lt;Binding ElementName="curveEditPoint" Path="V"/&gt;
                  &lt;Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:CurveEditor}}" Path="MinV"/&gt;
                  &lt;Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:CurveEditor}}" Path="MaxV"/&gt;
                  &lt;Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:CurveEditor}}" Path="ActualHeight"/&gt;                    
              &lt;/MultiBinding&gt;
          &lt;/TranslateTransform.Y&gt;
      &lt;/TranslateTransform&gt;
  &lt;/UserControl.RenderTransform&gt;
  </code></pre>
  
  <p>...
    </p>
  
  <p>For various reasons (but esp to avoid the relative source, I am now trying to do the same in code behind without success.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>    public CurvePointControl(CurveEditor CV)
      {
          InitializeComponent();
  
          MultiBinding multiBinding = new MultiBinding();
          multiBinding.Converter = m_VToYConverter;
  
          multiBinding.Bindings.Add(new Binding("V"));
          multiBinding.Bindings.Add(new Binding(CV.MinVProperty)); // doesn't work
          multiBinding.Bindings.Add(new Binding(CV.MaxVProperty)); // doesn't work
          multiBinding.Bindings.Add(new Binding(CV.ActualHeight)); // doesn't work       
          multiBinding.NotifyOnSourceUpdated= true;
  
          this.SetBinding(TranslateTransform.YProperty, multiBinding);
          //Doesn't work too:
          //BindingOperations.SetBinding(XTranslateTransform, TranslateTransform.YProperty, multiBinding);
  
      }
  </code></pre>
  
  <p>I still can't believe that it is so hard to convert the XAML into c# code. The converter is called but only once and without valid property values.</p>
  
  <p>Any idea of what's wrong?
  How could I debug such a problem?</p>