首页 > 解决方案 > 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();
        }
    }
}

这是怎么回事?我究竟做错了什么?这些都非常简单。

标签: xamlxamarinxamarin.forms

解决方案


A本身Rg.Plugins.Popup就是一个​​面,不能在ContentPage. 当想要显示一个弹出页面时,使用如下代码显示它们:

await PopupNavigation.Instance.PushAsync(new PopupTest());

将此代码放在您要显示的事件中PopupBackingPage。不需要支持页面,并且不会与Rg.Plugins.Popup页面一起使用。

希望这会有所帮助!


推荐阅读