1
我不知道我的代碼有什麼問題,但它顯示沒有錯誤,但是當我運行代碼時,沒有列表框出現在模擬器中。代碼的目的是在超鏈接元素旁邊顯示一個縮略圖圖像。我有已經檢查過所有的圖像位置都是有效的,並且所有的圖像都被設置爲類型內容。爲什麼我的類拒絕綁定到ListBox?
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>