SfPopup z index

Hello,

I have multiple popups on page. In case when more than one popup is shown is there a way for me to control z index of it?

Use case is that I have popup I show and user must interact. If condition for another popup is meet it will be shown over first one. I need a way to make sure user make choose on first popup before she/he can continue. Order of showing popups should not matter, I need one of them to be on top whenever it's shown.


8 Replies

KK Karthikraja Kalaimani Syncfusion Team July 3, 2021 05:08 PM UTC

Hi Milos,

Currently, we are validating your requirement. We will update the further details on or before 6th July 2021. We appreciate your patience until then. 

Regards,
Karthik Raja


KK Karthikraja Kalaimani Syncfusion Team July 6, 2021 04:09 PM UTC

Hi Milos, 

We don't have a direct support for your requirement. So, currently we are checking the possibilities to achieve your requirement with our source. So, we will update the further details on or before 8th July 2021. We appreciate your patience until then. 

Regards,
Karthik Raja


KK Karthikraja Kalaimani Syncfusion Team July 8, 2021 06:00 AM UTC

Hi Milos, 

Thanks for your patience. 

We figured out how to bring the popup to the front. So far, we've discovered a solution in Xamarin's Android platform. Please let us know if you require additional platforms. Please see the attached sample and the code snippet below.

Code snippet : 
public partial class MyPage : ContentPage
    {
        SfPopupLayout firstPopup;
        public MyPage()
        {
            InitializeComponent();
            firstPopup = new SfPopupLayout();

            firstPopup.PopupView.ContentTemplate = new DataTemplate(() =>
            {
                Button button = new Button();
                button.Text = "Click To open second popup";
                button.Clicked += Button_Clicked;
                return button;
            });

            firstPopup.PopupView.ShowFooter = false;
            firstPopup.PopupView.ShowHeader = false;
 
        }

        private void Button_Clicked(object sender, EventArgs e)
        {
            SfPopupLayout sfPopupLayout = new SfPopupLayout();
            sfPopupLayout.PopupView.ContentTemplate = new DataTemplate(() => {
                Button button = new Button();
                button.Text = "Bring the first popup to front";
                button.Clicked += Button_Clicked1;
                return button;

            });
            sfPopupLayout.Show();
        }

        private void Button_Clicked1(object sender, EventArgs e)
        {
            var nativeObject = (object)firstPopup.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("NativeObject")).GetValue(firstPopup);
            DependencyService.Get<IPopupHelper>().BringToFront(nativeObject);
        }

        void Button_Clicked_1(System.Object sender, System.EventArgs e)
        {
            firstPopup.Show();
        }
    }

    public interface IPopupHelper
    {
        void BringToFront(object obj);
    }

// Android project : 

[assembly: Dependency(typeof(Popup_Demo.Droid.PopupHelper))]
namespace Popup_Demo.Droid
{
    class PopupHelper : IPopupHelper
    {
        public void BringToFront(object obj)
        {
            var popupview = obj.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("PopupView")).GetValue(obj);
            var container = obj.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name.Equals("Container")).GetValue(obj);
            (container as FrameLayout).BringToFront();
        }
    }
}

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo1223017633.zip

Regards,
Karthik Raja


MK Milos Kajtez July 8, 2021 06:23 AM UTC

Hello,
I need to support Android, iOS and UWP.

As I have more popups it would be ideal to mark one as priority so it stay on top at all time. Or have a property for ordering all popups.



KK Karthikraja Kalaimani Syncfusion Team July 9, 2021 01:32 PM UTC

Hi Milos, 

Currently, we are validating your requirements. We will validate and update the further details on or before 13th July 2021. We appreciate your patience until then. 

Regards,
Karthik Raja


KK Karthikraja Kalaimani Syncfusion Team July 13, 2021 01:47 PM UTC

Hi Milos, 

We need some more time to analyse your requriement. So, we will update the further details on or before 15th July 2021. We appreciate your patience until then. 

Regards,
Karthik Raja


MA Mohanram Anbukkarasu Syncfusion Team July 15, 2021 02:02 PM UTC

Hi Milos, 

Thanks for your patience, 

We have achieved the reported requirement for XForms.iOS platform alone. We are facing difficulties on control architecture and Xamarin UWP platform level to achieve this same in XForms.UWP PopupLayout. We need some time to analyze the possibilities to provide workaround for UWP platform. So we will update the further details on or before July 20th ,2021. 

Code snippet for iOS: 
public void BringToFront(object obj) 
    var container = obj.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name.Equals("Container")).GetValue(obj); 
    var keyWindow = UIApplication.SharedApplication.KeyWindow; 
    keyWindow.BringSubviewToFront(container as UIView); 

Sample link: 

Thanks for your understanding. 

Regards, 
Mohanram A. 
 



KK Karthikraja Kalaimani Syncfusion Team July 20, 2021 09:04 AM UTC

Hi Milos, 

Please refer  to the below code snippets to bring the PopupView to front in Xamarin Forms UWP platform. 

Code snippets : 
 public void BringToFront(object obj)
        {
            var container = (Panel)obj.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name.Equals("Container")).GetValue(obj);
            var Popup = container.Parent as Popup;
            Popup.Child = null;
            Popup.Child = container;

        }

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo1223017633-67614008.zip

Regards,
Karthik Raja

Loader.
Up arrow icon