If each ListBoxItem
uses SelectedIndex + 1
, they will all display the same value since SelectedIndex
is a scalar. Moreover, this number will change as the user selects different ListBoxItems
. I suspect you actually want to display each item's index within the ListBox
+ 1.
To achieve this, you're probably best off using the ListBox
's ItemsContainerGenerator to get the index of the item within the container (see the IndexFromContainer method). You could look at exposing this from your data class, or perhaps look into an attached readonly property that retrieves this value for you.
HTH,
Kent