【发布时间】:2018-08-20 16:39:24
【问题描述】:
如何在 ListView 中设置图像的大小?
目标设备是 Windows Phone 10(即 Windows 通用平台)。
我发现了以下documentation:
请注意,当面向 Windows Phone 8.1 时,ImageCell 不会缩放 默认情况下的图像。另外,请注意 Windows Phone 8.1 是唯一的 以相同颜色和字体显示详细文本的平台 默认情况下作为主要文本。 Windows Phone 8.0 将 ImageCell 呈现为 见下图:
我试过了:
<ListView Grid.Row="1" ItemsSource="{Binding Photos}" SelectedItem="{Binding SelectedPhoto, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell ImageSource="{Binding ImageSource}" Text="{Binding Description}" TextColor="Silver" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
上图显示了一个完整的图像,没有限制图像的大小以适合列表视图项。
我也试过了:
<ListView Grid.Row="1" ItemsSource="{Binding Photos}" SelectedItem="{Binding SelectedPhoto, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding ImageSource}" Aspect="AspectFit" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
上面的代码没有显示任何图像。它只是显示一个白色背景。
【问题讨论】:
-
你试过设置宽度请求和水平选项吗?
标签: xamarin.forms