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
public Dictionary<TipContract, string> ComboTip
{
get
{
return TipContract_dict;
}
}
public Dictionary<Formatare, string> ComboFormatare
{
get { return Formatare_dict; }
}
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
<ComboBox x:Name="cmbTip"
IsEnabled="True"
SelectedValuePath="Value"
DisplayMemberPath="Tip"
SelectedValue="{Binding Formatare_dict}"