title: How to programmatically bind a System.Windows.Controls.Parameter to a ComboBox' SelectedItem in Silverlight
body: <p>I have the following sample from MSDN:</p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="White"&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="25" /&gt;
          &lt;RowDefinition Height="Auto" /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;riaControls:DomainDataSource Name="source" QueryName="GetProductsByColor" AutoLoad="true"&gt;
          &lt;riaControls:DomainDataSource.DomainContext&gt;
              &lt;domain:ProductDomainContext /&gt;
          &lt;/riaControls:DomainDataSource.DomainContext&gt;
          &lt;riaControls:DomainDataSource.QueryParameters&gt;
              &lt;riaControls:Parameter ParameterName="color" Value="{Binding ElementName=colorCombo, Path=SelectedItem.Content}" /&gt;
          &lt;/riaControls:DomainDataSource.QueryParameters&gt;
      &lt;/riaControls:DomainDataSource&gt;
      &lt;ComboBox Width="60"  Grid.Row="0" x:Name="colorCombo"&gt;
          &lt;ComboBoxItem Content="Black" /&gt;
          &lt;ComboBoxItem Content="Blue" /&gt;
      &lt;/ComboBox&gt;
      &lt;data:DataGrid Grid.Row="1" ItemsSource="{Binding Data, ElementName=source}" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Well, as you can see the line that creates a parameter binding is set:</p>
  
  <pre><code>&lt;riaControls:Parameter ParameterName="color" Value="{Binding ElementName=colorCombo, Path=SelectedItem.Content}" /&gt; 
  </code></pre>
  
  <p>However if I am to try this with code it doesn't work:</p>
  
  <pre><code>Binding binding = new Binding();
  binding.ElementName = "colorCombo";
  //binding.Source = this.colorCombo; also doesn't work!
  binding.Path = new PropertyPath("SelectedItem.Content");
  binding.Mode = BindingMode.OneWay;
  
  Parameter param = new Parameter();
  param.Value = binding;
  
  source.QueryParameters.Clear();
  source.QueryParameters.Add(param);
  </code></pre>
  
  <p>Any ideas on what I am doing wrong?</p>