로컬 고득점 (ObservableCollection) 세트가 있고이를 표시 할 수 있도록 ListBox에 바인딩 된 데이터입니다. 내가 현재 가지고있는 것은, 첫 번째 TextBlock의 "{Binding Index}"는 현재 항목의 색인을 가져 오는 중입니다. 그러나 데이터 바인딩을 통해 가능한지 확실하지 않습니다.데이터는 목록 상자의 항목 인덱스를 바인딩합니까?
<ListBox Grid.Row="1" x:Name="localScoresListBox" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Index}" Grid.Column="0" />
<TextBlock Text="{Binding PlayerName}" Grid.Column="1" />
<TextBlock Text="{Binding Score}" Grid.Column="2" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
내 질문에. 데이터 바인딩을 사용하여 현재 항목의 색인을 가져올 수 있습니까?
0- 기반이 될 수 있다고 생각하고 첫 번째 순위를 0 대신 1로 만들고 싶기 때문에 {Binding Index + 1}과 같은 작업을 수행 할 수 있습니까?
편집 : 비슷한 질문이 WPF 여기있어 다음 그것을 할 수있는 방법이있을 것 같지 않았다 중 하나 WPF ListBox bind to index of the item