all,
I am really stuck on a very basic concept - I just cannot find an answer that I really understand.
I have a view - viewContacts. Its datacontext is a viewmodel - viewmodelContacts.
On the view I have a combobox for 'titles' (you know ... Mr, Mrs, Miss, etc). I want to bind the itemssource so it shows a list of options, and bind the SelectedValue so that it stores the key in the viewmodelContacts TitleId property.
The 'source' list if titles (that I want to bind ItemsSource to) is actually in a separate static class - note NOT the viewmodel!
internal static class Titles
{
static IList<Title> _colTitles = null;
static Titles()
{
_colTitles = new List<Title>();
_colTitles.Add(new Title() { TitleId = 1, Description = "Mr." });
_colTitles.Add(new Title() { TitleId = 2, Description = "Mrs." });
_colTitles.Add(new Title() { TitleId = 3, Description = "Miss." });
_colTitles.Add(new Title() { TitleId = 4, Description = "Ms." });
}
internal static IList<Title> GetTitles()
{
return _colTitles;
}
}
(later on, of course, this stuff will be fetched from a database).
This simple task exceeds my talent as a WPF developer.
How do I set the ItemsSource to this static class? How do I further set the DisplayMemberPath to the Description property of the underlying Title object?
What do I set the SelectedValue and SelectedValuePath to?
Really hoping someone can help me out with what appears to be a simple problem that I just cannot work out.
Thanks, Gray