title: ComboxBox Data Binding and Default Selected Item using WCF RIA Services
body: <p>I am trying to bind the data to ComboBox using WCF RIA. Only for data binding is fine but on the same time I want to be already selected for the specified item after binding. For this case, I don't know how can I do to achieve this. May be the way that my data binding also wrong.</p>
  
  <p>Here is my Entity</p>
  
  <pre><code>public class Customer
  {
      [System.ComponentModel.DataAnnotations.Key()]
      public int CustomerId { get; set; }
      public string CustomerName { get; set; }
  }
  </code></pre>
  
  <p>Here is WCF RIA Service</p>
  
  <pre><code>public class CustomerDomainService : DomainService
  {
  
      public IEnumerable&lt;Customer&gt; GetCustomers()
      {
              List&lt;Customer&gt; rtnList = new List&lt;Customer&gt;();
              DataTable dt = (new CustomerBLL()).GetAllCustomers;
              foreach (DataRow dr in dt.Rows) {
                      rtnList.Add(new Customer {
                              CustomerId = Convert.ToInt32(dr("CustomerID")),
                              CustomerName = Convert.ToString(dr("CustomerName"))
                      });
              }
              return rtnList;
      }
  
  }
  </code></pre>
  
  <p>Here is XAML</p>
  
  <pre><code>&lt;ComboBox Name="CustomerComboBox" HorizontalAlignment="Left" Height="25" Width="150" Grid.Column="1" Grid.Row="1" ItemsSource="{Binding ElementName=CustomerDomainDataSource, Path=Data}" DisplayMemberPath="CustomerName" SelectedValuePath="CustomerId"/&gt;
          &lt;riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Customer, CreateList=true}" Height="0" Name="CustomerDomainDataSource" QueryName="GetCustomersQuery" Width="0"&gt;
              &lt;riaControls:DomainDataSource.DomainContext&gt;
                  &lt;my:CustomerDomainContext /&gt;
              &lt;/riaControls:DomainDataSource.DomainContext&gt;
          &lt;/riaControls:DomainDataSource&gt;
  </code></pre>
  
  <p>Regards</p>