title: C# Silverlight - Combobox with TwoWay Binding?
body: <h3>EDIT:</h3>
  <p>The Answer I was looking for was....</p>
  <pre><code>&lt;dataFormToolkit:DataField Label=&quot;Business Type:&quot;&gt;
                                          &lt;ComboBox x:Name=&quot;BusinessType&quot; SelectedItem=&quot;{Binding BusinessType, Mode=TwoWay}&quot; &gt;
                                              &lt;ComboBox.Items&gt;
                                                  &lt;sys:String&gt;Land&lt;/sys:String&gt;
                                                  &lt;sys:String&gt;Maritime&lt;/sys:String&gt;
                                              &lt;/ComboBox.Items&gt;
                                          &lt;/ComboBox&gt;
                                      &lt;/dataFormToolkit:DataField&gt;
  </code></pre>
  <p>Heres the link to the <a href="http://forums.silverlight.net/forums/t/126593.aspx" rel="nofollow noreferrer">article</a></p>
  <p>I have a c# silverlight business application that uses the ado.net entity framework and the domain service class to bind to my sql server database and pull data from/ persist data to my database. I have been using the dataformtoolkit namespace to layout textboxes which can be edited/display data, using a TwoWay binding mode in order to allow the read/write functionality.</p>
  <p>On some of the fields I want to use a combobox instead of a textbox in order to add a better user experience to my application. The impression i've got from reading around the web is that this isnt as easy as it should be.
  My current textbox code looks like:</p>
  <pre><code>&lt;dataFormToolkit:DataField&gt;
     &lt;TextBox Text=&quot;{Binding BusinessType, Mode=TwoWay}&quot; /&gt;
  &lt;/dataFormToolkit:DataField&gt;
  </code></pre>
  <p>my attempt at something similar is as follows but incorrect:</p>
  <pre><code>&lt;ComboBox&gt;
    &lt;ComboBox.Items&gt;
      &lt;ComboBoxItem Content=&quot;Maritime&quot; IsSelected=&quot;{Binding BusinessType, Mode=TwoWay}&quot; /&gt;
      &lt;ComboBoxItem Content=&quot;Land&quot; IsSelected=&quot;{Binding BusinessType, Mode=TwoWay}&quot; /&gt;
    &lt;/ComboBox.Items&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  <p>NB/ I want the combobox to be populated by a list or an enum etc. (preferably a list). The contents of the combobox should have nothing to do with the database, just that when the user hits submit the selection made in the combobox gets persisted back to the database. It is also important that the combobox can read from the database and display the specific selection that has already been made if this is the case.</p>
  <p>****EDIT:</p>
  <p>Current setup of dataform bound to datagrid with editable businesstype field as a textbox (I want to replace this textbox with a combobox that has two selectable items).</p>
  <pre><code> &lt;!--DataForm Declaration--&gt;
   &lt;dataFormToolkit:DataForm x:Name=&quot;dataForm1&quot; Height=&quot;410&quot; Width=&quot;331&quot;
                   VerticalAlignment=&quot;Top&quot;       
                   Header=&quot;Job Details&quot;
                   CurrentItem=&quot;{Binding SelectedItem, ElementName=dataGrid1}&quot; 
                   HorizontalAlignment=&quot;Left&quot; &gt;
             &lt;dataFormToolkit:DataForm.EditTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackPanel&gt;
                        &lt;dataFormToolkit:DataField&gt;
                          &lt;TextBox Text=&quot;{Binding BusinessType, Mode=TwoWay}&quot; /&gt;
                        &lt;/dataFormToolkit:DataField&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
             &lt;/dataFormToolkit:DataForm.EditTemplate&gt;
     &lt;/dataFormToolkit:DataForm&gt;
  </code></pre>
  <p>So how do i manipulate this code to use a combobox instead of a textbox?</p>
  <p>Any help in doing this would be greatly appreciated.</p>