TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vijay
NA
150
90.4k
Convert to 'System.Windows.Controls.ComboBox to int ?
Sep 5 2013 2:05 AM
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.....
Reply
Answers (
1
)
Datagrid using Silvelright 5
How to Save Captured image in Media Library in Windows Phone