0
我想將ListBox與媒體庫中的圖像綁定。如何將圖像從媒體庫數據綁定到列表框?
到現在我已經做到了這一點,但它似乎並沒有工作:
XAML代碼:
<ListBox Name="pictureHolder" FlowDirection="LeftToRight"
Width="445" Margin="0,417,12,26"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Name="imageFile" Source="{Binding Picture}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
CS代碼:
private void bindPictures()
{
pictureHolder.ItemsSource = library.Pictures;
}
有什麼不好的代碼? 任何幫助,將不勝感激。