I would like to display a Popup with the Xamarin Community Toolkit Popup, but I try to navigate to it using Shell I receive the error "System.NullReferenceException Message=Object reference not set to an instance of an object."
The xaml for my popup:
<?xml version="1.0" encoding="utf-8" ?>
<xct:Popup
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="Restuco_Tables.Views.AddAreaPopup"
Shell.PresentationMode="ModalAnimated"
Size="300, 300">
<StackLayout>
<Label Text="This is a Popup!" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
</StackLayout>
</xct:Popup>
The codebehind:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class AddAreaPopup : Popup
{
public AddAreaPopup()
{
InitializeComponent();
}
}
I have registered Routing in AppShell:
Routing.RegisterRoute(nameof(AddAreaPopup), typeof(AddAreaPopup));
My call to the Popup using Shell:
private async void tbiNewArea_Clicked(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("/AddAreaPopup");
}