I'm sending CommandParameter
to TapGestureRecognizer
, and it was available in object parameter of my OnTapGestureRecognizerTapped
function. But I'm unable to extract value from it. How can I fix this?
My list view (XAML markup):
<ListView x:Name="listViewEvents" RowHeight="120" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" FontSize="Large" Grid.ColumnSpan="2" Text="{Binding UploadTitle}" LineBreakMode="TailTruncation"></Label>
<Label Grid.Row="1" Grid.Column="0" Text="{Binding UploadDescription}" Font="Small" TextColor="Gray" LineBreakMode="TailTruncation"></Label>
<Image Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Source="{Binding AttachPath}" Aspect="AspectFill">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
NumberOfTapsRequired="2"
CommandParameter="{Binding AttachPath_New}"
/>
</Image.GestureRecognizers>
</Image>
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding FileName}" LineBreakMode="TailTruncation"></Label>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
My C# page :
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{
string fullPath = "";
Image imageSender = (Image)sender;
if (imageSender.GestureRecognizers.Count > 0)
{
fullPath = imageSender.GestureRecognizers[0].ToString();
}
DownloadFile(imageSender.Source.GetValue(UriImageSource.UriProperty).ToString());
}
Here I'm getting my value: