Binding WPF ComboBox to entity?

You can use a converter ( tutorial ), but that might be overdoing it a bit. I would recommend using the DisplayMemberPath property of the ComboBox.

You can use a converter (tutorial), but that might be overdoing it a bit. I would recommend using the DisplayMemberPath property of the ComboBox. To use a converter, you will need to create a converter class (one that implements IValueConverter.) Your code will look something like this: public object Convert(object value, Type targetType, object parameter, System.Globalization.

CultureInfo culture) { MyCompany.Data. Professional prof = (MyCompany.Data. Professional)value; if (prof == null) { return string.

Empty; } else { return string. Format("{0} {1}", prof. First, prof.

Last); //or however you want to format this } } // If you'll ever need to convert back from a string to a Professional, // implement that logic here public object ConvertBack(object value, Type targetType, object parameter, System.Globalization. CultureInfo culture) { return null; } In the XAML, you'll do something like this: Edit edit: In this case, I don't think you'll ever need to use ConvertBack, as you'll be able to get at the selected object by casting ComboBox. SelectedItem as a Professional.

For example, you'd want to use DisplayMemberPath="Data. Professional". Please let me know if this helped you out.

– oltman Oct 15 '09 at 0:42 1 The problem with the DisplayMemberPath is that the FirstName and LastName are separate fields. What I'd need is something like a DisplayMemberPath Template :) . So, how would you use the converter ( which property on the combobox)?

– Larry R Oct 15 '09 at 14:05 I didn't have enough space in the comments, but I updated my answer. Hope this helps :) – oltman Oct 15 '09 at 14:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions