我将项目绑定如下:
<ScrollViewer>
<ItemsControl x:Name="UserList">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding imageurl}"
Tag="{Binding Path=id}" Width="164" Height="150"
Margin="4" Stretch="Fill"></Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
Code.cs:
List.Add(new StackImages { id = "1", Name="test",type="test",price ="testprice" ,imageurl = new Uri(this.BaseUri, @"Assets/acservice.png") });
List.Add(new StackImages { id = "2", imageurl = new Uri(this.BaseUri, @"Assets/brakes.png") });
List.Add(new StackImages { id = "3", imageurl = new Uri(this.BaseUri, @"Assets/carwash.png") });
List.Add(new StackImages { id = "4", imageurl = new Uri(this.BaseUri, @"Assets/oilchange.png") });
List.Add(new StackImages { id = "5", imageurl = new Uri(this.BaseUri, @"Assets/transmission.png") });
UserList.ItemsSource= List;
请告诉我点击它时如何获取特定标签值的特定图像URL?