xaml - I cannot call another screen when I click on the image
问题描述
I have two images to simulate the click on the button, but I want is when clicking the image and change call another screen. And the process does not happen because the application is stopping
<StackLayout>
<!-- Place new controls here -->
<Image Source="botaocadastrolivre.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{
tapCount++;
var imageSender = (Image)sender;
// watch the monkey go from color to black&white!
if (tapCount % 2 == 0)
{
imageSender.Source = "botaocadastrolivre.png";
}
else
{
imageSender.Source = "botaocadastroPresed.png";
Navigation.PushAsync(new Nova());
}
// Task.Delay(100)
//Navigation.PushAsync(new Nova());
}
解决方案
转到您的App.xaml.cs
文件,找到类似以下内容的行:
MainPage = new MainPage();
并将其更改为:
MainPage = new NavigationPage(new MainPage());
这会将您的页面包装到导航页面中,然后该Navigation
对象将知道如何从一个页面导航到另一个页面。
阅读 Xamarin.Forms 中的导航概念可能是明智之举:https ://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/
推荐阅读
- azure-logic-apps - Logic Apps 液体模板询问
- android - 通过 WebRTC 为 Android 提供流媒体应用的建议
- syntax - 带有模块声明的一般语句中的 OCaml 语法错误
- r - 删除 R 中的加载包消息
- javascript - 从函数返回值到变量
- python - 有时需要“从...导入...”而简单的“导入...”并不总是有效吗?为什么?
- javascript - Flask:将二进制文件返回给客户端的问题
- javascript - 如何使用 JavaScript 将一个月中的天数插入到选项下拉列表中?
- java - 确定 GZIPOutputStream 行为
- python - (Python) psycopg2 安装