更新时间:2023-10-08 22:18:28
我有一个类似的问题,得到了此处
I had a similar question which was answered here
基本上,您将ListBox的 AlternationCount
设置为很高,绑定到每个项目上的 AlternationIndex
Basically you set the ListBox's AlternationCount
to something really high, and bind to the AlternationIndex
on each item
<ListBox AlternationCount="100">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},
Path=(ItemsControl.AlternationIndex)}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>