The exception is thrown only when I use the show() method, here's the code:
public partial class DetailOS : ContentPage
{
SfPopupLayout Popup { get; set; }
public string MotivoCancel { get; set; }
Models.Manutencao.Pedido Pedido { get; set; }
public DetailOS (Models.Manutencao.Pedido obj)
{
InitializeComponent ();
Pedido = obj;
Popup = new SfPopupLayout();
Popup.PopupView.AppearanceMode = AppearanceMode.TwoButton;
Popup.PopupView.HeaderTitle = "Cancelar OS";
Popup.PopupView.PopupStyle = new PopupStyle {
AcceptButtonBackgroundColor = Color.FromHex("#009530"),
AcceptButtonTextColor = Color.White,
DeclineButtonBackgroundColor = Color.FromHex("#009530"),
DeclineButtonTextColor = Color.White
};
Popup.PopupView.ContentTemplate = new DataTemplate(() => {
var txt = new Entry { Placeholder = "Informe o motivo" };
txt.BindingContext = this;
txt.SetBinding(Entry.TextProperty, "MotivoCancel");
return txt;
});
Popup.PopupView.DeclineButtonText = "VOLTAR";
Popup.PopupView.AcceptButtonText = "CANCELAR";
Popup.PopupView.AcceptCommand = new Command(Cancelar);
BindingContext = new ViewModels.Manutencao.DetailOS () { Pedido = obj, Navigation = Navigation };
}
async void CancelarPopUp(object sender, EventArgs e)
{
try {
if (Pedido.Status == "aberto") {
Popup.Show();
} else {
await DisplayAlert("Acesso Restrito", "Essa OS não pode ser cancelada em seu atual estágio do processo", "OK");
}
} catch (Exception ex) {
await DisplayAlert("Exceção : Contate o administrador", ex.Message, "dismiss");
}
}
}
Didn't include the whole class here, just the methods that have some interaction with the Popup.
I made sure to include the xmlns:syncfusion="clr-namespace:Syncfusion.XForms.PopupLayout;assembly=Syncfusion.SfPopupLayout.XForms" in the xaml.
The stack trace is the following:
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.XForms.Android.PopupLayout.RendererHelper.GetNativeRendererForFormsView (Xamarin.Forms.View view, Syncfusion.XForms.PopupLayout.SfPopupLayout valid) [0x00039] in :0
at Syncfusion.XForms.Android.PopupLayout.RendererHelper.ConvertFormsToNativeView (Syncfusion.XForms.PopupLayout.SfPopupLayout formsSfPopupLayout, Xamarin.Forms.View view, Android.Views.ViewGroup+LayoutParams layoutParams) [0x00000] in :0
at Syncfusion.XForms.Android.PopupLayout.RendererHelper.SetContentTemplateToNativePopupView (Syncfusion.XForms.Android.PopupLayout.PopupView nativePopupView, Syncfusion.XForms.PopupLayout.PopupView formsPopupView) [0x00037] in :0
at Syncfusion.XForms.Android.PopupLayout.RendererHelper.MapPopupViewProperties (System.String propertyName, Syncfusion.XForms.PopupLayout.PopupView formsPopupView, Syncfusion.XForms.Android.PopupLayout.PopupView nativePopupView) [0x00213] in :0
at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.MapPopupViewProperties (System.String propertyName) [0x00028] in :0
at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.CreateNativePopup (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout popup, System.Boolean canMap) [0x0012d] in :0
at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.Show (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout formsPopup) [0x00007] in :0
at Syncfusion.XForms.PopupLayout.SfPopupLayout.Show () [0x0000c] in <71ecd4ed02a74af885d8e5b7876b2bda>:0
at GFA.Views.Manutencao.DetailOS+d__13.MoveNext () [0x0004c] in C:\wampNew\www\App_GFA\GFA\GFA\GFA\Views\Manutencao\DetailOS.xaml.cs:44
Edit: I'm using version 16.4.0.46