Reputation:
I have a wpf combobox which I want to display a selection of strings
string[] list1= new string[]{"first","second"."third",fourth"} and so on
Xaml:
ComboBox Name="cmbItems"
ItemsSource="{Binding Path=list1}"
SelectedValue="{Binding Path=Display}"
where Display is the property in my ViewModel
public string Display
{
get
{
return _Person.Display;
}
set
{
_Person.Display = value;
NotifyPropertyChanged(() => Display);
}
}
when i run my code..the combobox displays nothing....
can somebody tell me what i am doing wrong
Thanks
Upvotes: 0
Views: 270
Reputation: 35
You have to set the string array to public property.
private string[] list1 = new string[] { "first", "second", "third", "fourth" };
public string[] List1 { get { return list1; } set { list1 = value; } }
Now bind to List1 (ItemsSource="{Binding Path=List1}")
Upvotes: 1