Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Listview selected item not working when using an image

$
0
0

I got something strange going on and I can't figure it out. I am using an image as icon that the user presses. And the image works fine but I can't click on the listview item it self nothing happens, I can delete it though. This is most likely caused by the tap gesture though I can change it to click gesture but the opposite thing happends. The listview works but not the image.

`
<ContentPage.Resources>



Blue

</ContentPage.Resources>

<ContentPage.Content>
    <RelativeLayout>
        <ListView ItemsSource="{Binding ListItems}" x:Name="llv" SelectedItem="{Binding SelectedListViewItem, Mode=TwoWay}" HasUnevenRows="True">
            <ListView.Header>
                <StackLayout Padding="10,5,0,5" VerticalOptions="Center" HorizontalOptions="Center">
                    <Label Text="{Binding Datetime}"/>
                </StackLayout>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout>
                            <StackLayout Orientation="Horizontal">
                                <Label Text="{Binding ItemName}" TextColor="{Binding SelectedColor}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" Margin="5,5,5,5" />
                                <Label Text="{Binding DateTimeSet}" Margin="5,5,5,5" VerticalOptions="Center" HorizontalOptions="End"/>
                                <Image Source="icon.png" VerticalOptions="CenterAndExpand" HeightRequest="20" WidthRequest="20" ClassId="{Binding Id}" >
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer
                                            Command="{Binding Path=BindingContext.PlayOrPauseButtonPressed, Source={x:Reference taskspageview}}" 
                                            NumberOfTapsRequired="1" CommandParameter="{Binding .}" >

                                        </TapGestureRecognizer>

                                    </Image.GestureRecognizers>
                                </Image>

                            </StackLayout>

                        </StackLayout>
                        <ViewCell.ContextActions>
                            <MenuItem Text="Delete" IsDestructive="True" Command="{Binding Source={x:Reference llv}, Path=BindingContext.DeleteSingleTask}"
                                CommandParameter="{Binding .}"/>
                        </ViewCell.ContextActions>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <controls:FloatingActionButton HorizontalOptions="CenterAndExpand" 
                                   WidthRequest="100" HeightRequest="100" 
                                   VerticalOptions="CenterAndExpand" 
                                   Command="{Binding AddButton}"
                                   Image="icon.png" ButtonColor="#03A9F4" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, 
            Property=Width, Factor=1, Constant= -98}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-98}" />
    </RelativeLayout>
</ContentPage.Content>


`


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>