Now, if I click on the grid, the Image change and the "Item is selected". But I need, if the User click at a CircleImage or at a Label, Go to a webview. And if click at the "SELECT Image" or other place, that is not the CircleImage or Label, mark the item as selected. So, may i add a CircleImage tap gesture to go to the webview and if whatever other place clicked, mark as selected (changing the SelectedImage) ?? Thanks.
I am trying to put my code, but not success.
|
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<listView:SfListView x:Name="listView" ItemSize="70" ItemsSource="{Binding contactsinfo}"SelectionMode="Single" ItemTapped="listView_ItemTapped">
<listView:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid x:Name="grid" RowSpacing="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ContactImage}" x:Name="image"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="50">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference listView},Path=BindingContext.ImageTappedCommand}" CommandParameter="{Binding .}"/>
</Image.GestureRecognizers>
</Image>
<Grid RowSpacing="1" Grid.Column="1">
<Grid.InputTransparent>
<OnPlatform x:TypeArguments="x:Boolean">
<OnPlatform.WinPhone>
<OnIdiom x:TypeArguments="x:Boolean" Phone="True" Tablet="True"Desktop="True" />
</OnPlatform.WinPhone>
<OnPlatform.Android>
<OnIdiom x:TypeArguments="x:Boolean"
Phone="False"
Tablet="False" />
</OnPlatform.Android>
<OnPlatform.iOS>
<OnIdiom x:TypeArguments="x:Boolean"
Phone="True"
Tablet="True" />
</OnPlatform.iOS>
</OnPlatform>
</Grid.InputTransparent>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference listView}, Path= BindingContext.GridTappedCommand}" CommandParameter="{Binding .}"/>
</Grid.GestureRecognizers>
<Grid RowSpacing="1"
Padding="10,0,0,0"
VerticalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label LineBreakMode="NoWrap"
TextColor="#474747"
Text="{Binding ContactName}">
</Label>
<Label Grid.Row="1"
Grid.Column="0"
TextColor="#474747"
LineBreakMode="NoWrap"
Text="{Binding ContactNumber}">
</Label>
</Grid>
<Grid Grid.Row="0"
Grid.Column="2"
RowSpacing="0"
HorizontalOptions="End"
Padding="0,10,10,0">
<Label LineBreakMode="NoWrap"
TextColor="#474747"
Text="{Binding ContactType}">
</Label>
</Grid>
</Grid>
<StackLayout Grid.Row="1" Grid.ColumnSpan="2" BackgroundColor="Gray"HeightRequest="1"/>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</listView:SfListView.ItemTemplate>
</listView:SfListView>
</Grid>
</ContentPage.Content> |
|
<ContentPage.Resources>
<ResourceDictionary>
<local:ImageSelectionConverter x:Key="ImageSelectionConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
…
<sync:SfListView x:Name="listView">
…
<sync:SfListView.ItemTemplate>
…
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1"/>
</Grid.GestureRecognizers>
<Label Grid.Row="0" Text="{Binding SongTitle}" FontAttributes="Bold" VerticalOptions="End" />
<Label Grid.Row="1" Text="{Binding SongAuther}" Font="Small" TextColor="#4BA0FB" VerticalOptions="Start"/>
<Image Grid.Row="0" Source="{Binding IsSelected, Converter=ImageSelectionConverter}"
…
</sync:SfListView.ItemTemplate>
</sync:SfListView> |
|
public class ImageSelectionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var isselected = (bool)value;
if (isselected)
return ImageSource.FromResource("CustomSelection.Images.Selected.png");
return ImageSource.FromResource("CustomSelection.Images.NotSelected.png");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |