I have a class called Name
with one property.
public class Name
{
public string comboName { get; set; }
}
I'm attempting to run a LINQ query to return all FullName
, and then create an instance of the Name
class for each, assigning FullName
to the property comboName
. The instances are added to a List
, and then I want List
values to be added to ComboBox1
drop down values. Below is the code I've written so far.
void ComboBox1_Loaded(object sender, RoutedEventArgs e)
{
GiftIdeasDataContext dc = new GiftIdeasDataContext();
var qry = from r in dc.Recipients
select new Name()
{
comboName = r.FullName
};
List<Name> lst = qry.ToList();
ComboBox1.ItemsSource = lst;
}
Issue: When the code is executed the ComboBox1
drop down only shows the string 'myMemory.Name' 9 times (the number of names which are in the Recipient
table). Should I just create a list and assign string values to the list instead of using a class?
I've only been using the console window with c# up to now, this is my first project using WPF, so any help is appreciated.