首页 > 解决方案 > 将 InputTransparent 属性设置为 True 的 ListView 正在影响 ListView 内的按钮

问题描述

我希望我的 ListView 不可滚动和可点击,所以我设置属性 InputTransparent = true,但是,我在 ListView 内也有按钮,所以我也无法点击按钮。我尝试将按钮的 InputTransparent 属性设置为 false,但它不起作用。

有什么建议,或者您知道任何解决方法,所以我可以只显示不可点击且不可滚动的列表?

这是我的 XAML

<ListView BackgroundColor="Blue" 
                                  ItemsSource="{Binding QuestionList}"
                                  SeparatorVisibility="None" 
                                  VerticalOptions="FillAndExpand"
                                  InputTransparent="True">

                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <StackLayout Orientation="Horizontal">
                                            <StackLayout HeightRequest="24" 
                                                         WidthRequest="24" 
                                                         Margin="0,0,16,0"
                                                         InputTransparent="True">
                                                <Frame CornerRadius="20" 
                                                       HasShadow="False" 
                                                       Padding="0" Margin="0" 
                                                       BackgroundColor="Blue" 
                                                       HeightRequest="24" 
                                                       WidthRequest="24">
                                                    <Label
                                                       FontSize="16" 
                                                       VerticalOptions="CenterAndExpand" 
                                                       HorizontalOptions="CenterAndExpand" 
                                                       Text="a" 
                                                       TextColor="White"/>
                                                </Frame>
                                            </StackLayout>
                                            <StackLayout Margin="16,0,68,0" WidthRequest="324" HorizontalOptions="FillAndExpand">
                                                <Label Text="{Binding Question}" />
                                            </StackLayout>
                                            
                                            <StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Margin="0,0,30.5,0" HeightRequest="30.5">
                                                <StackLayout Margin="0,0,12,0">
                                                    <Button HorizontalOptions="FillAndExpand" Text="YES" Command="{Binding }" WidthRequest="219" FontSize="12">

                                                    </Button>
                                                    <BoxView HeightRequest="1.52" HorizontalOptions="FillAndExpand" VerticalOptions="Start" Margin="0,-8,0,0"

                                                    </BoxView>
                                                </StackLayout>

                                                <StackLayout>
                                                    <Button HorizontalOptions="FillAndExpand" Text="NO" Command="{Binding }" WidthRequest="219" FontSize="12">

                                                    </Button>
                                                    <BoxView HeightRequest="1.52" HorizontalOptions="FillAndExpand" VerticalOptions="Start" Margin="0,-8,0,0">

                                                    </BoxView>
                                                </StackLayout>
                                            </StackLayout>
                                        </StackLayout>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>

标签: xamllistviewxamarin.forms

解决方案


推荐阅读