如何让ListBoxItem显示序号

  <ListBox ItemsSource="{Binding}" AlternationCount="{Binding Path=Count}">

            <ListBox.ItemTemplate>

                <DataTemplate>

                    <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem},

                                      Path=(ItemsControl.AlternationIndex)}" />

                </DataTemplate>

            </ListBox.ItemTemplate>

        </ListBox>

posted on 2011-10-20 13:40  beastplus  阅读(701)  评论(0编辑  收藏  举报

导航