我有个问题。我绑定ListView
到我的ObservableCollection<ImageSource>
:
<ListView x:Name="FramesListView" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Disabled"
ItemsSource="{Binding Path=FrameImages}" SelectionChanged="FramesListView_OnSelectionChanged">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel
Width="Auto"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Border Width="100" Height="75" BorderThickness="1" BorderBrush="DarkGray" VerticalAlignment="Center" Margin="7,5,7,5">
<StackPanel Orientation="Vertical">
<Image Margin="5,5,5,5" Width="100" Height="75" Source="{Binding}" Stretch="Fill"></Image>
<Label HorizontalAlignment="Center" Content="{Binding}"></Label>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
除了一件事,一切都很好。我还想在每个图像下显示索引。我不知道如何意识到这一点。
如何更改该行以使其成为可能?
<Label HorizontalAlignment="Center" Content="{Binding}"></Label>