-
Notifications
You must be signed in to change notification settings - Fork 455
NullReferenceException thrown in PopupRenderer.SetViewController when using in embedded forms scenario #1758
Description
Description
I am trying to use the Popup View in a Xamarin.iOS application embedding some Xamarin.Forms views, a technique described in the Xamarin.Forms documentation here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/native-forms
When calling Xamarin.Forms.Application.Current.MainPage.Navigation.ShowPopup(popup);
I get a null reference exception, as shown in the stack trace.
Stack Trace
System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.CommunityToolkit.UI.Views.PopupRenderer.SetViewController () [0x00089] in <be1d33109c044cbba821f6c39d395abb>:0
at Xamarin.CommunityToolkit.UI.Views.PopupRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x0001f] in <be1d33109c044cbba821f6c39d395abb>:0
at Xamarin.CommunityToolkit.UI.Views.PopupRenderer.Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0008d] in <be1d33109c044cbba821f6c39d395abb>:0
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.CommunityToolkit.Extensions.NavigationExtensions.PlatformShowPopup (Xamarin.CommunityToolkit.UI.Views.BasePopup popup) [0x00000] in <be1d33109c044cbba821f6c39d395abb>:0
at Xamarin.CommunityToolkit.Extensions.NavigationExtensions.ShowPopup (Xamarin.Forms.INavigation navigation, Xamarin.CommunityToolkit.UI.Views.BasePopup popup) [0x00000] in <be1d33109c044cbba821f6c39d395abb>:0
at XctEmbedDemo.MainViewController.OnTouchUpInside (System.Object sender, System.EventArgs e) [0x0000d] in /Users/follesoe/Projects/XctEmbedDemo/XctEmbedDemo/MainViewController.cs:51
Link to Reproduction Sample
I have created a minimal Xamarin.iOS application referencing the latest builds of Xamarin.Forms and Xamarin.CommunityToolkit that will trigger this issue: https://github.com/follesoe/XctEmbedDemo
Steps to Reproduce
- Run the example application
- Tap the button
- Observe the null reference exception
Expected Behavior
I would expect the popup to appear, or at least get a meaningful error saying I am using the component in an unsupported way.
Actual Behavior
Null reference exception is thrown.
Basic Information
- Version with issue: 1.3.1
- Last known good version:
- IDE:
- Platform Target Frameworks:
- iOS: 15.0,
- Xamarin.iOS: 15.2.0.17
- Android:
- UWP:
- Android Support Library Version:
- Nuget Packages:
- Affected Devices: