Convert to 'System.Windows.Controls.ComboBox to int ?
Cannot implicitly convert type 'System.Windows.Controls.ComboBox' to 'int?'
I am binding Enum values to combobox using this code,
xaml.cs:
ObservableCollection<string> genders = new ObservableCollection<string>();
public ObservableCollection<string> Genders
{
get { return genders; }
set { genders = value; }
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Type typegender = typeof(Gender);
FieldInfo[] arrGenderFieldValues = typegender.GetFields(BindingFlags.Public | BindingFlags.Static);
foreach (var gen in arrGenderFieldValues)
{
Genders.Add(gen.GetValue(null).ToString());
}
this.DataContext = this;
}
xaml :-
<ComboBox Grid.Row="2" Height="25" Width="90" Name="gender" ItemsSource=" {Binding Genders}"/>
now i have two 2 questions,
1. how to assign values
Employee emp= new Employee();
emp.Gender= ?
2. IS there any other possible way to bind enum values to combo box
please reply for this problems.....