Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

[iOS] ListView ItemTapped only raised on "LongTap"

MaruMaru DEMember ✭✭

Hi everyone,

I have a simple ListView with Labels inside of it and on Android the ItemTapped event is raised when normally tapped, but in iOS I need to touch for a long time before the event is raised.

Does anyone had this behavior before?

Best Answer

Answers

  • MaruMaru DEMember ✭✭

    push

  • NMackayNMackay GBInsider, University admin

    @Maru

    Have you tried with the latest build of Forms? works fine for me.

    <ListView Grid.Row="1" ItemsSource="{Binding Orders}" VerticalOptions="Fill" x:Name="ListviewOrder"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Image Source="{Binding OrderStatus, Converter={StaticResource OrderStatusToImage}}" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" /> <Label Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" FontSize="16" FontAttributes="Bold" Text="{Binding CustomerName}" /> <Label Grid.Row="1" Grid.Column="1" VerticalOptions="Start" FontSize="12" Text="{Binding OrderNo}" TextColor="{Binding OrderStatus, Converter={StaticResource OrderStatusToColor}}" /> <Label Grid.Row="1" Grid.Column="2" VerticalOptions="Start" FontSize="12" Text="{Binding AccCode}" /> </Grid> <b:Interaction.Behaviors> <b:BehaviorCollection> <b:EventToCommand CommandNameContext="{b:RelativeContext Home}" EventName="Tapped" CommandName="SelectCommand" CommandParameter="{Binding .}" /> </b:BehaviorCollection> </b:Interaction.Behaviors> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

  • MaruMaru DEMember ✭✭

    @NMackay Sadly this didn't do the trick.

    answerList = new ListView
    {
        BackgroundColor = Color.FromHex("#F5731B"),
        Header = new StackLayout
        {
            Padding = new Thickness(0, 0, 0, 15),
            Children = 
            {
                new Label
                {
                    Text = "Text",
                    XAlign = TextAlignment.Center,
                    YAlign = TextAlignment.Center
                }
            }
        },
        ItemsSource = answersCollection,
        ItemTemplate = new DataTemplate(() =>
        {
            Label label = new Label
            {
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };
            label.SetBinding(Label.TextProperty, "Text");
    
            return new ViewCell
            {
                View = label
            };
        })
    };
    answerList.ItemTapped += answerSelected;
    
  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    That bug came only up, when you used ContextActions. But Maru didn't use any.
    Maybe there is/was also a problem when you use a header? I didn't try that.

    Nevertheless, they did change something (fixed bug 26032) on iOS regarding the ItemTapped behavior, so you should retest with 1.4.4-pre1.

  • MaruMaru DEMember ✭✭

    @NMackay @MichaelRumpler Checked and the issue is still there :/

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    Too bad.

    Can you try if my sample project from https://bugzilla.xamarin.com/show_bug.cgi?id=26032 works for you? I did that yesterday minutes before I saw your post and it worked with the new XF version on my iPad 2.

    If this works, then you have to find the differences between the two solutions and file a bug yourself. Just add your features to my sample project until it does not work anymore. Then attach that sample to the new bug so that Xamarin can easily reproduce it.

  • SevakDevSevakDev Member

    I have the same problem now, only LongTap raises ItemTapp in ios. any suggestion?

Sign In or Register to comment.