I want a base class for my Popups to inherit from, that handles callbacks.
My approach: Create a class ("CallbackPopup") that inherits from PopupPage ( https://github.com/rotorgames/Rg.Plugins.Popup ) Create XAML+CS files that inherit from CallbackPopup
CallbackPopup: (My base class for my custom popups)
using Rg.Plugins.Popup.Pages;
namespace MyProject
{
public class CallbackPopup : PopupPage
{
//[...]
}
}
Inheriting Class - XAML:
<?xml version="1.0" encoding="utf-8" ?>
<myproject:CallbackPopup xmlns="http://xamarin.com/schemas/2014/forms" <!-- throws the error -->
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:myproject="clr-namespace:MyProject;assembly=MyProject"
x:Class="MyProject.Layout.Popups.InheritingPopup">
<CallbackPopup.Content>
<!-- [...] -->
</CallbackPopup.Content>
</myproject:CallbackPopup>
Inheriting Class - CS:
using Rg.Plugins.Popup.Services;
using System;
using Xamarin.Forms.Xaml;
namespace MyProject.Layout.Popups
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class InheritingPopup: CallbackPopup
{
public InheritingPopup()
{
InitializeComponent();
}
// [...]
}
Error:
Type CallbackPopup not found in xmlns http://xamarin.com/schemas/2014/forms
I have tested the functionallity of the Popups and it has been successful. However creating it as a base class and make other popups inherit from it is not working as my error states. Am I missing something in the XAML declarations, or is inheriting from RG Plugins PopupPage causing the issue?
http://www.burkharts.net/apps/blog/the-secret-life-of-a-xaml-page/ states: "You cannot derive a Xaml defined Page from another Xaml defined page (unless they only define resources and no content)" May that be the cause of the problem? I don't know, if the RG Plugins PopupPages are Xaml defined pages that define more than resources and content.
Thanks for your support!
Well you should put myproject
namespace when you initialize CallbackPopup.Content
. That's what error is trying to tell you about :)
Something like this:
<myproject:CallbackPopup.Content>
<!-- [...] -->
</myproject:CallbackPopup.Content>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.