Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! i have created a List<string> data; property that i have added many string to.

i use this as a itemssource for my combobox.
In this case what should i use as the DisplayMemberPath. At the moment my combobox isn't displaying any data.

C#
public List<string> Country { get; set; }
                    Country = e.Result.Select(x => x.Country).Distinct().ToList();

                    SolvingTimeData = e.Result;
                    ComboBoxCountry.ItemsSource = Country;
//                    ComboBoxCountry.DisplayMemberPath = "";
                    ComboBoxCountry.SelectedItem = 0;</string>



Thanks!
Posted

1 solution

How have you set the binding in the xaml? Normally you would set the ItemsSource in the xaml, and then in your code behind you would set the DataContext to the List<string></string> something like this

C#
<ComboBox ItemsSource="{Binding}" Name="cbo"/>
and in your code behind

C#
List<string> countries = new List<string>();
          //fill list
          cbo.DataContext = countries;


Hope this helps
 
Share this answer
 
v2
Comments
CrafterIt 21-Jun-11 4:39am    
Yes, this solved it thanks!
Wayne Gaylard 21-Jun-11 4:41am    
Pleasure!
Sergey Alexandrovich Kryukov 21-Jun-11 16:45pm    
That is the answer, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900