1
I made this code to fill out a combobox. It works perfectly, but I need besides the text to be presented in the combo, also need to load a kind of Value, as we do on the web where we have Name and Value. I use WPF. If I fill the combo in time design like this:
<ComboBoxItem Content="Milho" Name="M"/>
            <ComboBoxItem Content="Soja" Name="S"/>
            <ComboBoxItem Content="Feijão" Name="F"/>
See that the name works as a Value and I can get this value in the code Behind. This is code to fill the combo in Runtime:
public void CarregaComboSecagem()
        {
            ListaSecagens lista = new ListaSecagens();
            ObservableCollection<string> listaCtg;
            var prod = lista.listaSecagens();
            listaCtg = new ObservableCollection<string>();
            foreach (var prd in prod)
            {
                listaCtg.Add(prd.Umidade.ToString());
            }
            cbxSecagem.ItemsSource = listaCtg;
        }
Prod is the list:
public class ListaSecagens
    {
        private SiloContext contexto = new SiloContext();
        public List<Secagem> listaSecagens()
        {
            return contexto.Secagens.ToList();
        }
    }
My Drying Essence
[Table("Secagem")]
    public class Secagem
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int IdSecagem { get; set; }
        public int IdProduto { get; set; }
        public decimal Umidade { get; set; }
        public decimal Desconto { get; set; }
        public decimal Valor_Sec { get; set; }
    }
My context
public class SiloContext : DbContext
    {
        public SiloContext()
            : base("SiloConn")
        {
            Database.SetInitializer<SiloContext>(null);
        }
        public DbSet<Produto> Produtos { get; set; }
        public DbSet<Balanca> Balancas { get; set; }
        public DbSet<Secagem> Secagens { get; set; }
    }
						
what kind of
prod?– Rovann Linhalis
@Rovannlinhalis, I edited the post and put the list class
– pnet