悬赏分:5 浏览:167 次
|
同时显示照片和文字可以使用DataTemplate,如下代码所示,你可以自行做调整:
<ListBox x:Name="myListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock x:Name="name" Text="{Binding MyName}"></TextBlock>
<Image x:Name="image" Source="{Binding MySource}"></Image>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
如果我没记错的话Silverlight 2中的BitmapImage继承于ImageSource,而Image对象的Source属性定义如下:
public ImageSource Source { get; set; }
所以应该可以直接进行数据绑定。
希望对你有所帮助! |