I have an WPF form with a listbox and a button on it.
I populate a listbox (tagbox) with the List and then bind this with datasource as below.
private void WeekFood_Load(object sender, EventArgs e)
{
List<string> tags = new List<string>() { "A", "B", "C"};
tagbox.DataSource = tags;
InitializeComponent();
}
Then when I click the button, I run the following code
private void GenSunday_Click(object sender, EventArgs e)
{
MessageBox.Show(tagbox.SelectedItems.Count.ToString());
}
No matter how many items are selected in the listbox it always returns 0 with tagbox.SelectedItems always being null.
I have tried populating the box by iterating the list with valuemember and displaymember however this also does not fix things.
How is this fixable.
Many thanks in advance