浮动操作按钮在ListView上无法正常工作

时间:2018-02-13 17:17:22

标签: xaml listview xamarin floating-action-button

我在列表视图上有一个浮动操作按钮。当列表为空或具有较少条目时,浮动操作按钮工作正常,但当列表填满浮动操作按钮时无法点击。在这种情况下,当我尝试单击浮动操作按钮时,单击列表项。

  <AbsoluteLayout>
            <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
                <ListView IsPullToRefreshEnabled="{Binding CanExecute}"
                          IsRefreshing="{Binding CanExecute, Converter={StaticResource xyzConverter}}"
                          ItemsSource="{Binding Assessments, Converter={StaticResource abcConverter}}"
                          IsEnabled="{Binding CanExecute}"
                          HasUnevenRows="True"
                          x:Name="ListContent">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid HeightRequest="34"
                                      Padding="16, 20, 16, 20"
                                      RowSpacing="0">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="18" />
                                        <RowDefinition Height="16" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="24" />
                                        <ColumnDefinition Width="48" />
                                    </Grid.ColumnDefinitions>
                                    <Label HorizontalTextAlignment="Start"
                                       VerticalTextAlignment="End"
                                       FontSize="16"
                                       FontAttributes="Bold"
                                       LineBreakMode="WordWrap"
                                       Grid.Column="0"
                                       Grid.Row="0"
                                       Text="{Binding Name}"/>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>
            <Custom:FloatingActionButtonView 
                AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                HasShadow="True"
                Size="Normal"
                ImageName="new.png"
                x:Name="FAB"
                ColorNormal="{x:Static Constants:Colors.Primary}"
                Command="{Binding MyCommand}"/>
        </AbsoluteLayout>

1 个答案:

答案 0 :(得分:0)

尝试此操作,将您的按钮插入StackLayout

<StackLayout>
    <Custom:FloatingActionButtonView 
                AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                HasShadow="True"
                Size="Normal"
                ImageName="new.png"
                x:Name="FAB"
                ColorNormal="{x:Static Constants:Colors.Primary}"
                Command="{Binding MyCommand}"/>
</StackLayout>