我正在使用Xamarin形式的刷卡。 问题是我无法在卡内执行点击事件。
这是我的Xaml代码 -
<swipecards:CardStackView
Grid.Row="0"
x:Name="CardStackView"
ItemsSource="{Binding Cards[0]}"
Swiped="CardStackView_Swiped"
StartedDragging="CardStackView_dragged"
Margin="20"
BackgroundColor="#E0E0E0"
Focused="CardStackView_Focused">
<swipecards:CardStackView.ItemTemplate>
<DataTemplate>
<Grid RowSpacing="1" ColumnSpacing="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout
Orientation="Horizontal"
Grid.Row="0"
Grid.ColumnSpan="2">
<Label
Text="{Binding .FullJobName}"
HorizontalOptions="Start"
Style="{StaticResource TitleLabel}"/>
<Grid VerticalOptions="Start">
<Image
x:Name="MyImage"
Source="{Binding .CompanyProfImg}"
HorizontalOptions="FillAndExpand"
Aspect="AspectFit" />
<ActivityIndicator
BindingContext="{x:Reference MyImage}"
IsRunning="{Binding IsLoading}}"/>
</Grid>
</StackLayout>
<StackLayout Grid.Row="1" Grid.ColumnSpan="2">
<Label
Text="{Binding .LocationName}"
HorizontalOptions="StartAndExpand"
Style="{StaticResource label_med}"/>
<Label
Text="{Binding .TotalSalary }"
Style="{StaticResource label_med}"/>
</StackLayout>
<StackLayout Grid.Row="2" Grid.ColumnSpan="2">
<Label
Text="Comapny Name"
Style="{StaticResource TitleLabel}"
HorizontalOptions="StartAndExpand"/>
<Label
Text="{Binding .CompanyName}"
HorizontalOptions="StartAndExpand"
Style="{StaticResource label_med}"/>
</StackLayout>
<StackLayout Grid.Row="3" Grid.ColumnSpan="2">
<Label
Text="Key Skills"
Style="{StaticResource TitleLabel}"
HorizontalOptions="StartAndExpand"/>
<Label
Text="{Binding .Skills}"
HorizontalOptions="StartAndExpand"
Style="{StaticResource label_med}"/>
</StackLayout>
<StackLayout Grid.Row="4" Grid.ColumnSpan="2">
<Label
Text="Job Description"
Style="{StaticResource TitleLabel}"
HorizontalOptions="StartAndExpand"/>
<Label
Text="{Binding .Description}"
HorizontalOptions="StartAndExpand"
Style="{StaticResource label_med}"/>
</StackLayout>
<StackLayout Grid.Row="5" Grid.ColumnSpan="2">
<BoxView Color="#DCDCDC" HeightRequest="2" />
<StackLayout Orientation="Horizontal">
<Label
Text="{Binding .Postedby}"
HorizontalOptions="Start"
Style="{StaticResource label_med}"/>
<Image x:Name="More_Option" Source="more.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding TapCommand}"
CommandParameter="Image1"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
</StackLayout>
</Grid>
</DataTemplate>
</swipecards:CardStackView.ItemTemplate>
</swipecards:CardStackView>
和ViewModel看起来像这样 -
private ICommand tapCommand;
public ICommand TapCommand
{
get { return tapCommand; }
set
{
OnTapped(this.tapCommand);
}
}
void OnTapped(object s)
{
}
我的代码出了什么问题?我也尝试过正常的方法,正常的点击事件。但这也没有用。 我正在引用此链接 - Link
谢谢你们。