Xamarin Forms ListView onpressing event

AliErenAliEren BEMember ✭✭

I want to change the Image by changing the IconToShow propery with binding (programmatically), when the item is pressing.

How can I trigger an OnPressed event ??

<ListView x:Name="listView" ItemSelected="OnItemSelected" ItemsSource="{Binding MainMenuList}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" IsVisible="{Binding MenuStyle, Converter={StaticResource not}" SeparatorColor="Blue">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.View>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="50" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10" />
                                <ColumnDefinition Width="30" />
                                <ColumnDefinition Width="10" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Image Source="{Binding IconToShow}" Grid.Row="0" Grid.Column="1"/>
                            <Label Text="{Binding Title}" Grid.Row="0" Grid.Column="3"/>
                        </Grid>
                    </ViewCell.View>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

Best Answers

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Add a TapGestureRecognizer to your icon and set the IconToShow property on Tapped event

  • AliErenAliEren BEMember ✭✭
    edited July 2016

    @NMackay
    MR.Gestures is a licensed package ??

    @AlessandroCaliaro
    That doesn't exactly do what I want, it raises an event when you stop pressing and I must have an event that can be raised when I'm pressing.

  • NMackayNMackay GBInsider, University mod

    @AliEren

    Yes but it costs 10 euros per app to licence. You'll spend a lot more in man hours trying to figure how to do it with custom renderers. I'm not a sales agent for @MichaelRumpler either before you ask :wink:

Sign In or Register to comment.