We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SFPopupLayout produces NullReference on IsOpen = true after navigation (xamarin forms)

I'm using an SfPopup defined in xaml and binding to the IsOpen property. This is on a navigation page that contains a grid with two rows, the second of which is height *. Here is the popup definition:

 <sfPopup:SfPopupLayout Grid.Row="1" x:Name="InfoPopup" 
                           IsOpen="{Binding IsInfoOpen, Mode=TwoWay}" />
  

On first navigating to this page, there is no issue, and the popup can be opened/closed multiple times. After navigating back, then forward again to the same page, the popup produces a NullReference exception when IsOpen changes to true. All other controls on the page work fine, including an SfDataGrid. I tried removing the binding to IsOpen and using .Show(), but that produced the same issue. This is with version 16.3.0.29 on iOS 12, xamarin forms version 3.3.0.967583. Have also tested with rowspan = 2. 


Stacktrace:
"  at Syncfusion.XForms.iOS.PopupLayout.SfPopupLayout.ResizePopupView () [0x001e4] in <1356613810c24590a725cab6be10944b>:0   at Syncfusion.XForms.iOS.PopupLayout.SfPopupLayout.DisplayPopup () [0x00026] in <1356613810c24590a725cab6be10944b>:0   at Syncfusion.XForms.iOS.PopupLayout.SfPopupLayout.set_IsOpen (System.Boolean value) [0x00024] in <1356613810c24590a725cab6be10944b>:0   at Syncfusion.XForms.iOS.PopupLayout.RendererHelper.MapSfPopupLayoutProperties (System.String propertyName, Syncfusion.XForms.PopupLayout.SfPopupLayout formsPopupLayout, Syncfusion.XForms.iOS.PopupLayout.SfPopupLayout nativePopupLayout) [0x0003c] in <1356613810c24590a725cab6be10944b>:0   at Syncfusion.XForms.iOS.PopupLayout.PopupLayoutDependencyService.MapSfPopupLayoutProperties (System.String propertyName, Syncfusion.XForms.PopupLayout.SfPopupLayout formsPopup) [0x00010] in <1356613810c24590a725cab6be10944b>:0   at Syncfusion.XForms.PopupLayout.SfPopupLayout.OnIsOpenChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00042] in <6491071ab4dc4290b46b78b9473c7fd0>:0   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:625   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:417   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00225] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindingExpression.cs:173   at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindingExpression.cs:57   at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindingExpression.cs:615   at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.10/src/Xamarin.iOS/Foundation/NSAction.cs:152 "

3 Replies

VR Vigneshkumar Ramasamy Syncfusion Team November 20, 2018 10:20 AM UTC

Hi Ben,  
 
Thanks for contacting Syncfusion Support.   
 
We checked your query and the shared code. From the code snippet, we are able to get that you are using SfPopupLayout in a wrong use case.   
 
SfPopupLayout can only be the root of the page, but in your code snippet, you have added it as the child of the Grid, which is a wrong use case.  
 
SfPopupLayout can be used in two ways,   
Displaying pop-up when the SfPopupLayout is set as root view : Popup can be displayed when it is set as the root view of the page. Please refer the below UG link for more details on how to show popup when popup is the root view. 
  
Displaying pop-up when the SfPopupLayout is not set as root view : Popup can be displayed by calling it on the fly, please refer the below UG link for more details on how to show popup on the fly. 
  
 
We prepared the sample as per your requirement to display popup in the navigation page, where SfPopupLayout.IsOpen is binded to the property in the ViewModel. Please find the code snippet of the same below.  
 
<ContentPage.BindingContext>  
    <local:ViewModel />  
</ContentPage.BindingContext>  
  
<sfpopup:SfPopupLayout x:Name="popup" IsOpen="{Binding DisplayPopup}">  
    <sfpopup:SfPopupLayout.Content>  
        <Grid>  
            <Grid.RowDefinitions>  
                <RowDefinition />  
                <RowDefinition Height="*"/>  
            </Grid.RowDefinitions>  
            <Button Grid.Row="0" Text="Click to open popup" Command="{BindingOpenPopupCommand}"/>  
        </Grid>  
    </sfpopup:SfPopupLayout.Content>  
</sfpopup:SfPopupLayout>  
 
You can download the sample from the below link.  
 
Regards,  
Vigneshkumar R 



BR Ben Reierson November 20, 2018 10:31 AM UTC

Ok, thanks for the help. To be honest, I don't understand why it would have this restriction. My feedback/request is to consider enhancing SfPopupLayout to allow for both methods of showing it, regardless of whether it's the rootview. 


VR Vigneshkumar Ramasamy Syncfusion Team November 26, 2018 12:59 PM UTC

Hi Ben,  
  
We have analyzed your query “Popup has not displayed while popup is set as content of Grid”, Due to some restrictions we were unable to display the popup at desired position as per your requirement, Hence we have logged the bug report for the same, The issue will be fixed our any one of the upcoming release. Also we have provide the work around sample in the following link.  
  
  
Disclaimer : The date for the issue fix is tentative and not a commitment on our parts.  
  
  
Regards,  
Vigneshkumar R 


Loader.
Live Chat Icon For mobile
Up arrow icon