首页 文章

禁用列表上的突出显示单击以查看xaml页面Xamarin.Forms

提问于
浏览
0

我在xaml页面中有List:

<ListView x:Name="ListTypeView" ItemsSource="{Binding ResourceType}" BackgroundColor="#FFFFFF" HeightRequest="210" WidthRequest="300" HorizontalOptions="CenterAndExpand" RowHeight="30">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout StyleId="Settings_StackLayout" Orientation="Horizontal" Padding="0" Margin="50,0,0,0">
                    <Label FontSize="Medium" HorizontalOptions="StartAndExpand" Text="{Binding ResourceType}" TextColor="Black" VerticalOptions="Center" WidthRequest="100"></Label>
                    <Image x:Name="Image" Source="{Binding Checkbox}" HorizontalOptions="StartAndExpand" WidthRequest="18" HeightRequest="18">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer Command="{Binding Source={x:Reference ListTypeView}, Path=BindingContext.ListTypeChangeCommand}" CommandParameter="{Binding .}"/>
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

我想禁用listView上的高亮显示单击(删除列表选择器,默认为蓝色)

1 回答

  • 0

    如果您在图像上定义TapGestureRecognizer,那么如果您点击图像,则无论如何都不应该选择列表项 . 如果要在项目点击上禁用选择器,则需要使用不同的事件 - 列表项目

    lstItems.ItemTapped += LstItems_ItemTapped;
    

    然后

    private void LstItems_ItemTapped(object sender, ItemTappedEventArgs e)
            {
                //do whatever you need with selected item and reset it
                ((ListView)sender).SelectedItem = null;
            }
    

相关问题