WPF - Bind to Item Index from within ItemTemplate of ItemsControl?
问题 Is there a way to bind to the ItemIndex from within the ItemTemplate of an ItemsControl? For example: <ItemsControl ItemsSource=\"{Binding Path=ItemList}\"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text=\"{Binding Path=ThisItemsIndex}\" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> 回答1: If you're not using any type of alternating row styles you might be able to hijack the AlternationIndex for this. Set AlternationCount on your ItemsControl to something greater