【发布时间】:2013-04-11 22:30:12
【问题描述】:
我有一个 WP 应用程序,我想在其中显示一个图像列表,这些图像数据绑定到从 Web 服务填充的 observablecollection。我希望图像列表以与检索它们的位置相同的高度和宽度显示。那么,如何让图像控件根据数据绑定源自动调整其高度和宽度。
使用以下代码,图像不显示。
<Grid x:Name="LayoutRoot">
<Image Source="{Binding AlbumPicture}" Stretch="Fill" Width="Auto" Height="Auto"/>
</Grid>
以下工作,但每个图像的高度和宽度都不同。所以,它们看起来不太好。
<Grid x:Name="LayoutRoot">
<Image Source="{Binding AlbumPicture}" Stretch="Fill" Width="200" Height="120"/>
</Grid>
我尝试了以下方法,但它们没有奏效。
设置 Stretch="None"
-
Databind Image 控件的 Height、Width 属性到那些 使用以下图像,高度和宽度始终为0。
BitmapImage bmp = new BitmapImage(new Uri(updatedAlbum.AlbumPicture, UriKind.RelativeOrAbsolute)); album.AlbumHeight = bmp.PixelHeight; album.AlbumWidth = bmp.PixelWidth;
【问题讨论】:
标签: image windows-phone-7 data-binding