12

I want my combobox item names and values to be taken from my List of course I don't want my view model to hold combobox items list.

I got a list a,b,c,d

i want my combobox to have items

my viewmodel got

public List<string> PropsList { get; set; }

my view got

<ComboBox Name="cbPropName" ItemsSource="PropsList"/>

it gives me combo with P r o p s L i s t

:(

2 Answers 2

13

Nahum you'll have to use ItemsSource="{Binding PropsList}", assuming PropsList is a Dependancy property in your code behind or, even better, a property in your data context that implements INotifyPropertyChanged. In your case you'd have to set the DataContext property of your View to be the ViewModel

Sign up to request clarification or add additional context in comments.

2 Comments

It happens for me all the time, even after writing so many XAML lines :-). If it was helpful you could V my answer...
sure =D theres jsut that 10 minute wait thingy. people in this ite are just too fast.
2

try this:

 <ComboBox Name="cbPropName" ItemsSource="{Binding Path=PropsList}" />

also check this out: Binding WPF ComboBox to a Custom List

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.