title: Gets value from combobox in wpf binding by entity framework
body: <p>I bind my combobox from entityframework and when I try to get value from my combobox by selecting value it gives back text like this {NameOfCompany = Name } How can i get only the value Name?</p>
  
  <p>Thats the code in xaml</p>
  
  <pre><code> &lt;ComboBox  SelectionChanged="ComboFirma_SelectionChanged" Name="ComboFirma"  Margin="109,10,10,0" Height="28" VerticalAlignment="Top"&gt;
  &lt;ComboBox.ItemTemplate&gt;
     &lt;DataTemplate&gt;
       &lt;TextBlock Name="txbCombo" Text="{Binding NameOfCompany}"&gt;&lt;/TextBlock&gt;
      &lt;/DataTemplate&gt;
   &lt;/ComboBox.ItemTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>And I bind it like this.</p>
  
  <pre><code>var query2 = from f in model.Firmas
                       select new
                       {
                           f.NameOfCompany
                       };
  ComboFirma.ItemsSource = query2.ToList();
  </code></pre>
  
  <p>I tried something like this to gets the selected value but always i get an exception.</p>
  
  <pre><code>var str = (TextBox)ComboFirma.Template.FindName("txbCombo", ComboFirma);
          lblCompanyNameShow.Content = str.SelectedText;
  </code></pre>