に追加されたアイテムに自動的に番号を付けたいと思いGridView
ます。できれば、 のオブジェクトにプロパティを追加する必要がない方法でItemsSource
。
私の試みはItemContainerStyle
's Template
(楽しみのために単純化されています) を使用してきましたが、現在のアイテムのインデックスを取得できるようにバインドできるものは見つかりませんでした:
<Style x:Key="fooStyle"
TargetType="GridViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridViewItem">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="numbering"
Text="{Binding to what exactly}" />
<ContentPresenter x:Name="contentPresenter" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
numbering
TextBlock
がリスト内のアイテムの番号を確実に受け取るにはどうすればよいでしょうか?
これは Windows ランタイム用であることに注意してください。