1
我遇到問題。我必將ListView
我ObservableCollection<ImageSource>
:綁定到ObservableCollection的索引
<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>