我不知道我的代码有什么问题,它没有显示错误,但是当我运行代码时,模拟器中没有出现列表框。代码的目的是在超链接元素旁边显示缩略图。我已经检查过了所有图像位置都是有效的,并且所有图像都已设置为类型内容。
public class element
{
public string imageLocation { get; set; }
public string name {get; set; }
}
var source = List<element>();
//I then populate source with 4 elements (code omitted)
//The source list was created successfully
listBoxName.itemsSource = source;
在 Xaml 中
<ListBox Name ="listBoxName"
HorizontalAlignment="Left"
VerticalAlignment="Top"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas Name="List"
Tap="tapped_Click"
Background="Blue"
Height="100" Margin="0,0,0,0">
<Image Name="Thumbnail"
Source="{Binding imageLocation}"
Height="102" Width="126" />
<HyperlinkButton Name="link"
Content="{Binding name}"
Margin="0,0,0,84" Canvas.Left="128"
Canvas.Top="2" Height="96" Width="348"
FontSize="30" HorizontalAlignment="Left"/>
</Canvas>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>