Я пытаюсь сделать TapGestureRecognizer на некоторых кадрах, но когда я тестирую его, ничего не происходит.
XAML
<StackLayout>
<AbsoluteLayout>
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TranslationY="380" TranslationX="12.5" HeightRequest="60" WidthRequest="120">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Sport_Clicked"/>
</Frame.GestureRecognizers>
<StackLayout Orientation="Vertical" Padding="0" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" Spacing="-10">
<Label Text="Sport" FontSize="17"/>
</StackLayout>
</StackLayout>
</Frame>
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TranslationY="380" TranslationX="187.5" HeightRequest="60" WidthRequest="120">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Voeding_Clicked"/>
</Frame.GestureRecognizers>
<StackLayout Orientation="Vertical" Padding="0" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" Spacing="-10">
<Label Text="Voeding" FontSize="17"/>
</StackLayout>
</StackLayout>
</Frame>
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TranslationY="495" TranslationX="12.5" HeightRequest="60" WidthRequest="120">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Slaap_Clicked"/>
</Frame.GestureRecognizers>
<StackLayout Orientation="Vertical" Padding="0" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" Spacing="-10">
<Label Text="Slaap" FontSize="17" />
</StackLayout>
</StackLayout>
</Frame>
</AbsoluteLayout>
</StackLayout>
CS
void Sport_Clicked(object sender, EventArgs e)
{
new NavigationPage(new SportPage());
}
void Voeding_Clicked(object sender, EventArgs e)
{
new NavigationPage(new VoedingPage());
}
void Slaap_Clicked(object sender, EventArgs e)
{
new NavigationPage(new SlaapPage());
}
Я не получаю никаких предупреждений или ошибок при тестировании. Есть ли что-то, что перекрывает кадры, которые вы не видите, что вызывает блокировку ввода?
Edit:
Вот так выглядит кадр со следующим кодом
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TranslationY="380" TranslationX="187.5" HeightRequest="60" WidthRequest="120" BackgroundColor="Yellow">
<StackLayout Orientation="Vertical" Padding="0" HorizontalOptions="FillAndExpand" BackgroundColor="Green">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="Voeding_Clicked"/>
</StackLayout.GestureRecognizers>
<StackLayout Orientation="Horizontal" Spacing="-10" BackgroundColor="Red">
<Label Text="Voeding" FontSize="17"/>
</StackLayout>
</StackLayout>
</Frame>
С помощью этого кода я смогу щелкнуть зеленую часть и получить ответ, но я не понимаю? Есть ли способ иметь что-то, что будет перекрывать весь кадр, чтобы я мог использовать это для нажатия на кнопку?