tags:

views:

35

answers:

1

I have a person class with two properties, Name an Age. I know how to use databinding to display a collection of person in a wpf list box and how to modify the listitemtemplate to customize how each person is displayed.

Now I'd like to number each person on the list according to the order they appear on the list (which could change as the the items were sorted via name or age in the display). Is there a way to do that with the item template so instead of having a list like

Rob - 14

John - 56

Suzy - 32

it would be

1) Rob - 14

2) John - 56

3) Suzy - 32

Basically i'd like to do something like:

<ListView.ItemTemplate>
<DataTemplate>
    <WrapPanel> 
        **<TextBlock Text="{Binding CurrentPositionInList}"  />**
        <TextBlock Text="{Binding Path=Name}"  />
        <TextBlock Text="{Binding Path=Age}" /> 
    </WrapPanel> 
</DataTemplate>

Thanks in advance!

+1  A: 

http://stackoverflow.com/questions/745568/numbered-listbox

Wallstreet Programmer
thanks! i knew someone had to have asked this i just couldn't find it!
evan