【发布时间】:2017-10-30 19:49:18
【问题描述】:
我想在 ListView 的 Image 单元格项目周围留出一些空间:
<StackLayout>
<ListView ItemsSource="{Binding Items}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell Text="{Binding Title}" ImageSource="{Binding Image}" TextColor="Black" DetailColor="Gray"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
但是ImageCell 没有可用的 Margin 属性?
编辑
在发布问题之前,我按照 cvanbeek 的建议做了:
<DataTemplate>
<StackLayout Padding="5">
<ImageCell Text="{Binding Title}" ImageSource="{Binding Image}" TextColor="Black" DetailColor="Gray"/>
</StackLayout>
</DataTemplate>
但我得到了这个例外:
未处理的异常:
System.InvalidCastException:指定的强制转换无效。
在 MainActivity.cs 的 OnCreate 方法中
【问题讨论】:
-
你可以用带有填充的
StackLayout包围它 -
不可能,请参阅编辑
标签: xaml xamarin xamarin.ios xamarin.forms xamarin.android