I can’t figure this out, consider the following code:
<ListBox Width="200"
ItemsSource="{Binding CurrentArticle.ArticleCategories}"
DisplayMemberPath="{Binding Category.Name}">
</ListBox>
ArticleCategories is a table in my database that contains 2 foreign keys, 1 to Article and 1 to Categories, so ArticleCategories is a list that contains Articles and Categories.
I want to show which categories the current article(CurrentArticle) have in this listbox and I can’t figure out how to do so. I want to show Category.Name for each Category in the ListBox.
Right now, the listbox is showing “Data.ArticleCategory” because it dont know how to display it.
I have tried DisplayMemberPath="Category.Name" without success.
Do I need to use some sort of Data Template, if so, how?
Thank you.
DisplayMemberPath is not a field where you add a binding, its just the name of your Property on the given Item.
DisplayMemberPath="Name"should be enough.