xaml - Xamarin:在 Xaml 中制作 Rg 插件弹出窗口?
问题描述
我在尝试在 Xaml 中实例化弹出页面时遇到各种奇怪的错误。这是最让人头疼的:
No property, bindable property, or event found for 'Content', or mismatching type between value and property.
这是显示弹出窗口的页面:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns ="http://xamarin.com/schemas/2014/forms"
xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class ="PopupPages.PopupBackingPage"
xmlns:popup ="clr-namespace:PopupPages"
BackgroundColor="Transparent">
<popup:PopupTest />
</ContentPage>
这是它的代码隐藏:
namespace PopupPages
{
public partial class PopupBackingPage : ContentPage
{
public PopupBackingPage()
{
InitializeComponent();
}
}
}
这是弹出页面本身,在 xaml 中:
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
x:Class="PopupPages.PopupTest">
</pages:PopupPage>
这是弹出页面本身的代码隐藏:
namespace PopupPages
{
public partial class PopupTest : Rg.Plugins.Popup.Pages.PopupPage
{
public PopupTest()
{
InitializeComponent();
}
}
}
这是怎么回事?我究竟做错了什么?这些都非常简单。
解决方案
A本身Rg.Plugins.Popup
就是一个页面,不能在ContentPage
. 当想要显示一个弹出页面时,使用如下代码显示它们:
await PopupNavigation.Instance.PushAsync(new PopupTest());
将此代码放在您要显示的事件中PopupBackingPage
。不需要支持页面,并且不会与Rg.Plugins.Popup
页面一起使用。
希望这会有所帮助!
推荐阅读
- javascript - 在我运行命令时使用 node.js 和 discord.js 库向用户发送消息,但它仅在目标用户运行命令后才开始工作
- android - 我需要使用 C++ UE4 在文件中导入 ActivityInfo
- jsonschema - OpenAPI 是否允许 $ref 指向 _specific_ 枚举值?
- java - Microsoft Graph API 无需用户登录即可获取令牌
- numpy - 如何从具有相同大小的特征向量构建协方差矩阵
- c# - 从角度 8 的剑道调度程序中删除或隐藏时间行
- javascript - 使用 Laravel Mix 不会显示元素 UI 图标
- laravel - 在 url 上使用 /admin 时给出 404 响应
- segmentation-fault - 如何修复分段错误 guvcview
- python - argparse 仅当存在另一个参数时才传递文件