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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Second popup is not show before is property IsOpen set to false

Thread ID:

Created:

Updated:

Platform:

Replies:

141165 Nov 27,2018 04:39 PM UTC Nov 29,2018 07:23 AM UTC Xamarin.Forms 3
loading
Tags: SfPopup
Jan Najlepsi
Asked On November 27, 2018 04:40 PM UTC

I created simple dialog service which wrap Popup control.

public class DialogService : IDialogService
{
private SfPopupLayout popupLayout;
public void ShowConfirm(string title, string question, Action okCallback, Action noCallback)
{
var vm = new ConfirmDialogViewModel(okCallback, noCallback) {Question = question};
popupLayout = new SfPopupLayout
{
PopupView =
{
ShowHeader = true,
ShowFooter = true,
ShowCloseButton = false,
HeaderTitle = title,
AppearanceMode = AppearanceMode.TwoButton
}
};
var templateView = new DataTemplate(() => new ConfirmDialogView
{
BindingContext = vm
});
popupLayout.PopupView.ContentTemplate = templateView;
popupLayout.Show();
}
public void HideConfirm()
{
popupLayout.IsOpen = false;
}
}


I scenario when

1. Open popup_1
2. Close popup_1 from code, set property IsOpen to false
3. Open popup_2

Popup 2 is not show.

_dialogService.ShowConfirm("title_1", "question_1", () => {}, ()=>{});
_dialogService.HideConfirm();
_dialogService.ShowConfirm("title_2", "question_2", () => { }, () => { });

What is wrong? I need close popup_1 from code only way I found is set property is IsOpen to false.


Vigneshkumar Ramasamy [Syncfusion]
Replied On November 28, 2018 01:20 PM UTC

Hi Jan,  
  
Thanks for contacting Syncfusion Support.  
  
We checked your code snippet, you are creating the instance of SfPopupLayout each time when you are calling the ShowConfirm() method, you need to create the SfPopupLayout instance globally and call it whenever you need to show the popup. Please find the modified code sample below in which SfPopupLayout is created only once and called whenever needed.  
  
public class DialogService : IDialogService  
{  
  
private SfPopupLayout popupLayout;  
  
public void CreatePopup()  
{  
popupLayout = new SfPopupLayout  
{  
PopupView =  
{  
ShowHeader = true,  
ShowFooter = true,  
ShowCloseButton = false,  
AppearanceMode = AppearanceMode.TwoButton  
}  
};  
}  
  
public void ShowConfirm(string title, string question, Action okCallback, Action noCallback)  
{  
var vm = new ConfirmDialogViewModel(okCallback, noCallback) {Question = question};  
popupLayout.PopupView.HeaderTitle = title;  
  
var templateView = new DataTemplate(() => new ConfirmDialogView  
{  
BindingContext = vm  
});  
popupLayout.PopupView.ContentTemplate = templateView;  
popupLayout.Show();  
}  
public void HideConfirm()  
{  
popupLayout.IsOpen = false;  
}  
}  
  
_ dialogService.CreatePopup();  
_dialogService.ShowConfirm("title_1", "question_1", () => {}, ()=>{});  
_dialogService.HideConfirm();  
_dialogService.ShowConfirm("title_2", "question_2", () => { }, () => { });  
  
  
Please let us know if this is helpful.  
  
Regards,  
Vigneshkumar R 


Jan Najlepsi
Replied On November 28, 2018 02:42 PM UTC

Hello Vigneshkumar

Your solution not work for me. I use syncfusion xamarin forms controls in MVVM scenerio (Xamarin forms, PRISM, Syncfusion).

I created singleton DialogService which is injected in ViewModels classes.

Complete code of DialogService is in the attachments.


Usages:

  _dialogService.Init();
  _dialogService.ShowBusyDialog("Doing something amazing");
  _dialogService.HideBusyDialog();
  _dialogService.ShowError("Error message', () => { });

Same behavior as before. Second popup is open and close.




Attachment: DialogService_6d626df9.zip

Vigneshkumar Ramasamy [Syncfusion]
Replied On November 29, 2018 07:23 AM UTC

Hi Jan,  
 
We checked your query, “Second Popup Open and Close”, as in the below screenshot.  
 
   
We are able to reproduce it, when all the actions as in the below screenshot is done one by one immediately.   
 
   
 
The popup opens and closes immediately because, the popup will be opened and closed asynchronously, since the animation is running in popup for opening and closing. So, you cannot show the popup again before it closes. You can fix this issue in sample by either setting theSfPopupLayout.PopupView.AnimationMode as None or showing the popup 1 and closing it and again opening the popup 2 asynchronously. Please find the code snippet of the same below.  
 
Code snippet for Solution 1: SfPopupLayout.PopupView.AnimationMode as None  
public void Init()  
{  
    popupLayout = new SfPopupLayout  
    {  
        PopupView =  
        {  
            ShowHeader = true,  
            ShowFooter = true,  
            ShowCloseButton = false,  
            AppearanceMode = AppearanceMode.TwoButton,  
            AnimationMode = AnimationMode.None,  
        }  
    };  
}  
 
Code snippet for Solution 2: showing the popup 1 and closing it and again opening the popup 2 asynchronously  
Close1PopupAndShow2 = new Command(async () =>  
{  
    dialog.Show("Show Popup1", null, null, null);  
    await Task.Delay(100);  
    dialog.HideConfirm();  
    await Task.Delay(100);  
    dialog.Show("Show Popup2", null, null, null);  
});  
 
We have prepared the sample as per your requirement, you can download the same from the below link.  
 
Regards,  
Vigneshkumar R  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;