title: Select element in WPF Combobox from Nhibernate
body: <p>I have a dude, i want to select a value from wpf Combobox</p>
  
  <p>I have the next code:</p>
  
  <pre><code>    private void CargarUnidades()
      {
          List&lt;Unidades&gt; unidades;
  
          using (var sesion = NHibernateFluentConfiguracion.AbrirSesion())
          {
              using (var transaccion = sesion.BeginTransaction())
              {
                  unidades = Unidades.ObtenerTodaslasUnidades();
              }
          }
  
  
          cmbUnidad.ItemsSource = unidades;
  
          cmbUnidad.DisplayMemberPath = "Nombre";
          cmbUnidad.SelectedValuePath = "Nombre";
  
      }
  </code></pre>
  
  <blockquote>
    <p>After I charge the unidades</p>
  </blockquote>
  
  <pre><code>            CargarUnidades(); //Charge all unidades in the combobox
  
              Articulos c = Articulos.Obtener(id_articulo); 
              //Get Articulo from the database for the id
  
  
              //In the last query I get the unidad same that exists in cmbUnidad
              //previusly charge
  
              //I assing the value but in the combobox doesnt appear selected, 
              //appear nothing
              cmbUnidad.SelectedValue = c.id_unidad;
              txtCodigo.Text = c.Codigo;
              .
              .
              .
              .
  </code></pre>
  
  <p>How I can select a value from combobox??? 
  Note: I m new in WPF and my english is not good je je je</p>
  
  <p>Thanks for the answer Firo, I modify the code and this is the result</p>
  
  <pre><code>cmbUnidad.Items.Cast&lt;Unidades&gt;().FirstOrDefault(u =&gt; u.id_unidad == c.id_unidad.id_unidad);  
  </code></pre>
  
  <p>I dont know if this is the best way but its functionaly :P</p>