- Home
- Forum
- Xamarin.Forms
- Handle swiped item image click using prism...
Handle swiped item image click using prism...
Trying to handle clicking on a image in the leftswipe area. Using prism as below..but tapping on a image does nothing and produces no error.
Any suuggestion?
............................
<sync:SfListView.LeftSwipeTemplate>
<DataTemplate x:Name="LeftSwipeTemplate1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="Favorites.png"
WidthRequest="35">
<Image.GestureRecognizers> //NOT WORKING
<TapGestureRecognizer NumberOfTapsRequired="2" Tapped="{Binding SelectFavCommand}" />
</Image.GestureRecognizers>
</Image>
</Grid>
</Grid>
<Grid
Grid.Column="1"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="Delete.png"
WidthRequest="35" />
</Grid>
</Grid>
<Grid
Grid.Column="2"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="site.png"
WidthRequest="35" />
</Grid>
</Grid>
</Grid>
</DataTemplate>
</sync:SfListView.LeftSwipeTemplate>
<DataTemplate x:Name="LeftSwipeTemplate1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="Favorites.png"
WidthRequest="35">
<Image.GestureRecognizers> //NOT WORKING
<TapGestureRecognizer NumberOfTapsRequired="2" Tapped="{Binding SelectFavCommand}" />
</Image.GestureRecognizers>
</Image>
</Grid>
</Grid>
<Grid
Grid.Column="1"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="Delete.png"
WidthRequest="35" />
</Grid>
</Grid>
<Grid
Grid.Column="2"
BackgroundColor="#009EDA"
HorizontalOptions="Fill"
VerticalOptions="Fill">
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Image
Grid.Row="0"
Grid.Column="0"
BackgroundColor="Transparent"
HeightRequest="35"
Source="site.png"
WidthRequest="35" />
</Grid>
</Grid>
</Grid>
</DataTemplate>
</sync:SfListView.LeftSwipeTemplate>
.................................
//VIEW MODEL
public DelegateCommand<object> SelectFavCommand { get; set; }
public ClientsViewModel(INavigationService navigationService, IPageDialogService ipageserve, IEventAggregator ea)
{
_navigationService = navigationService;
SelectFavCommand = new DelegateCommand<object>(SelectFavCommandHandler);
}
private void SelectFavCommandHandler(object sender)
{
//NEVER REACHES HERE
}
{
_navigationService = navigationService;
SelectFavCommand = new DelegateCommand<object>(SelectFavCommandHandler);
}
private void SelectFavCommandHandler(object sender)
{
//NEVER REACHES HERE
}
SIGN IN To post a reply.
3 Replies
DB
Dinesh Babu Yadav
Syncfusion Team
June 4, 2018 01:10 PM UTC
Hi Anthony,
Thank you for using Syncfusion Products.
We would like to let you know that the binding context of each list view item in the ItemTemplate or LeftSwipeTemplate property would be the respective data model and so, when the command in ViewModel which is bind to list view item does not triggered on tapping the image. However, you can overcome this, by defining the respective Source property in the Command as like below code example.
Code Example[XAML]:
|
<sync:SfListView.LeftSwipeTemplate>
<DataTemplate x:Name="LeftSwipeTemplate1"> <Grid HorizontalOptions="Center" VerticalOptions="Center"> <Image BackgroundColor="Transparent" HeightRequest="35" Source="Favorites.png" WidthRequest="35"> <Image.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.ImageCommand, Source={x:Reference Name=listView}}" />
</Image.GestureRecognizers>
</Image> </Grid> </DataTemplate>
</sync:SfListView.LeftSwipeTemplate> |
For your reference, we have attached the sample in which tapped command in ViewModel gets triggered on tapping the nested list view item and you can download it from the below link.
Kindly let us know if you require further assistance.
Regards,
Sangeetha Raju
AN
Anthony
June 10, 2018 12:40 PM UTC
all solved thanks.
RS
Rawoof Sharief Muthuja Sherif
Syncfusion Team
June 11, 2018 05:16 AM UTC
Hi Anthony,
Thanks for the update.
Regards,
Rawoof M.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
AN Anthony
- Jun 1, 2018 04:21 PM UTC
- Jun 11, 2018 05:16 AM UTC