views:

98

answers:

2

Hello,

I've got an application, which uses many listBoxes with data attached to them using listBox.ItemsSource. The problem is it creates entries like [namespace].[class_name].

How can I create a template, which will replace entries with, eg. class "Name" field?

I look forward to hear from you soon, MattheW

+1  A: 

[namespace].[classname] is the default implementation of the ToString method, which is called if you don't specify what to display.

You can use the DisplayMemberPath property to specify which member of the class you want to display :

<ListBox ItemsSource="{Binding Persons}" DisplayMemberPath="Name" />

If you want more control on how the items are displayed, you can define a DataTemplate for your data type and assign it to the ItemTemplate property of the ListBox

Thomas Levesque
A: 

A good example of ListBox implementation is here

http://www.c-sharpcorner.com/UploadFile/dpatra/534/

Andrei Drynov