我正在使用具有android和IOS项目的xamarin.forms PCL
我创建了一个usercontrol(stacklayout中的两个标签)
我想为usercontrol创建click事件。
以下是代码:
.xaml代码
<local:DashboardBox Grid.Row="2" Grid.Column="0" SLBGColor ="#2E74B5" BoxTitle="
 + 
 Income">
<local:DashboardBox.GestureRecognizers>
<TapGestureRecognizer
Tapped="onInComeTapped"/>
</local:DashboardBox.GestureRecognizers>
</local:DashboardBox>
.cs代码
async void onInComeTapped(object sender, EventArgs args)
{
await Navigation.PushModalAsync(new Income());
}
UserControl代码:
<?xml version="1.0" encoding="utf-8" ?>
<StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BudgetManager.Control.DashboardBox">
<StackLayout x:Name="SL" WidthRequest="150" HeightRequest="150" Padding="0,10,0,10">
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Label x:Name="lblTitle" Grid.Row="0" TextColor="White" FontSize="20" HorizontalTextAlignment="Center"></Label>
<Label x:Name="lblValue" VerticalOptions="EndAndExpand" Grid.Row="1" TextColor="White" FontSize="20" HorizontalTextAlignment="Center"> </Label>
</Grid>
</StackLayout>
</StackLayout>
当我点击usercontrol事件时,“onIncomeTapped”没有调用
请建议我如何在usercontrol上调用click事件。