Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Why does ListBox require a DataTemplate to display item names correctly?

$
0
0

I have a WPF ListBox bound to an ObservableCollection of IProducts. If I specify

DisplayMemberPath="{Binding Path=IProductName}"

As part of the ListBox definition in XAML, I get a list of items that looks like this:

System.Data.Entity.DynamicProxies....
System.Data.Entity.DynamicProxies....
System.Data.Entity.DynamicProxies....
System.Data.Entity.DynamicProxies....
System.Data.Entity.DynamicProxies....

But if I specify an item template:

<ListBox.ItemTemplate><DataTemplate><Label Content="{Binding Path=IProductName}" /></DataTemplate></ListBox.ItemTemplate>

I get the actual product names...

Specifying the template is not a big deal, but I am curious as to why DisplayMemberPath doesn't work in this scenario.

Thanks.

J


http://digitalcamel.blogspot.com/


Viewing all articles
Browse latest Browse all 18858

Trending Articles