私は DataRow の ObservableCollection に設定された itemssource を持つ Listbox を持っています。この例では、各 DataRow に 5 つの列があるとします。
ListBox の DataTemplate には、5 つのテキストブロック (各列に 1 つ) があります。私の質問は、行のインデクサーにバインドして列の値を取得するにはどうすればよいですか?
これが私の試みですが、何も表示されないため、構文が間違っている必要があります。
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=.[0]}" />
<TextBlock Text="{Binding Path=.[1]}" />
<TextBlock Text="{Binding Path=.[2]}" />
<TextBlock Text="{Binding Path=.[3]}" />
<TextBlock Text="{Binding Path=.[4]}" />
</StackPanel>
</DataTemplate>
私はすでに次のようなことを行っているので、バインディングでインデクサーを使用できることを知っています。
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Collection[0].Name}" />
<TextBlock Text="{Binding Path=Collection[1].Name}" />
<TextBlock Text="{Binding Path=Collection[2].Name}" />
<TextBlock Text="{Binding Path=Collection[3].Name}" />
<TextBlock Text="{Binding Path=Collection[4].Name}" />
</StackPanel>
</DataTemplate>
私の構文を修正するための助けをいただければ幸いです。