我希望把图像在我的列表框使用绑定。
下面是包含URI的对象:
_roomView.Room = new Room
{
Items = new List<Item> {
new Item {ItemType = ItemType.BlueKey, ImageUri = "/Escape;component/Images/Items/a.jpg"},
new Item {ItemType = ItemType.Bracelet, ImageUri = "/Escape;component/Images/Items/b.png"},
new Item {ItemType = ItemType.Money, ImageUri = "/Escape;component/Images/Items/b.png"}}
};
DataContext = _roomView;
下面是XML:
<ListBox x:Name="Mylist">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="5">
<Image Source="{Binding Room.Items.ImageUri}" Stretch="None" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
图像没有显示。
任何人都可以看到,我错了?