Click here to Skip to main content
15,890,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello! I'm new to C# mvvm and I would like to find out how do i bind a list i create to my comboBox.

What I have tried:

VM
C#
public Dictionary<TipContract, string> ComboTip
        {
            get
            {
                return TipContract_dict;
            }

        }

        public Dictionary<Formatare, string> ComboFormatare
        {
            get { return Formatare_dict; }

        }



        //TipContract enum and dict to hold and display in combo boxes
        public enum TipContract
        {
            C, N, D, T, M, L
        }

        public static readonly Dictionary<TipContract, string> TipContract_dict = new Dictionary<TipContract, string>()
        {
            {TipContract.C, "Caracter"},
            {TipContract.N, "Numeric"},
            {TipContract.D, "Data"},
            {TipContract.T, "DataTime"},
            {TipContract.M, "Memo"},
            {TipContract.L, "Logic"},

        };
        
        
        public enum Formatare
        {
            Lower, Upper, Proper
        }

        public static readonly Dictionary<Formatare, string> Formatare_dict = new Dictionary<Formatare, string>(){
            {Formatare.Lower, "lower"},
            {Formatare.Upper, "UPPER"},
            {Formatare.Proper, "Proper"},
            
        };
XML
XML
<ComboBox  x:Name="cmbTip" 
                               IsEnabled="True"
                               SelectedValuePath="Value" 
                               DisplayMemberPath="Tip"
                               SelectedValue="{Binding Formatare_dict}"
Posted
Updated 28-Apr-17 3:33am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900