FlowListView列间距

时间:2018-07-31 08:18:57

标签: c# xaml xamarin xamarin.forms

我使用Flowlistview在水平位置显示5张图像,但是列之间的默认间距太大,如何减小间距并增加图片大小?

下面是我所做的:

enter image description here

我的流列表代码如下:

<controls:FlowListView   HeightRequest="70"  HorizontalOptions="Center" VerticalOptions="Start" Margin="0,5,0,0" FlowColumnMinWidth="70" SeparatorVisibility="None" HasUnevenRows="True" FlowItemsSource="{Binding Feedbackitems}"  FlowLastTappedItem="{Binding SelectedItem}" >
            <controls:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <controls:FlowStackCell Padding="0">
                    <StackLayout >
                            <forms:CachedImage HeightRequest="66"  WidthRequest="66"  DownsampleUseDipUnits="false"  Source="{Binding ImgEmojiSelected}" IsVisible="False" IsEnabled="false">
                                <forms:CachedImage.Triggers>
                                    <DataTrigger TargetType="forms:CachedImage" Binding="{Binding Selected, Converter={StaticResource cnvInvert}}" Value="ImgEmojiSelected">
                                        <Setter Property="IsVisible" Value="True" />
                                        <Setter Property="IsEnabled" Value="True" />
                                    </DataTrigger>
                                </forms:CachedImage.Triggers>
                            </forms:CachedImage>
                            <forms:CachedImage  HeightRequest="66" WidthRequest="66"  DownsampleUseDipUnits="false"  Source="{Binding ImgEmojiUnSelected}" IsVisible="False" IsEnabled="false">
                            <forms:CachedImage.Triggers>
                                <DataTrigger TargetType="forms:CachedImage" Binding="{Binding Selected, Converter={StaticResource cnvInvert}}" Value="ImgEmojiUnSelected">
                                    <Setter Property="IsVisible" Value="True" />
                                    <Setter Property="IsEnabled" Value="True" />
                                </DataTrigger>
                            </forms:CachedImage.Triggers>
                        </forms:CachedImage>
                    </StackLayout>
                    </controls:FlowStackCell>
                </DataTemplate>
            </controls:FlowListView.FlowColumnTemplate>
        </controls:FlowListView>

1 个答案:

答案 0 :(得分:1)

也许您可以使用类似的方法,以便将stacklayout包装到FlowListView中并定义图像之间所需的填充。如果我正确理解了您的问题,那么这对我有用。

<controls:FlowListView FlowColumnCount="3" 
                       HorizontalOptions="StartAndExpand"                           
                       SeparatorVisibility="Default" 
                       RowHeight="160"
                       Margin="7"
                       FlowItemsSource="{Binding Photos}">
    
    <controls:FlowListView.FlowColumnTemplate>
        <DataTemplate >
            <StackLayout Padding="3" >
                <Image Source="{Binding PersonalPhoto}"                        
                       VerticalOptions="FillAndExpand" 
                       Aspect="AspectFill"/>
            </StackLayout>
        </DataTemplate>
    </controls:FlowListView.FlowColumnTemplate>
</controls:FlowListView>