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.
| 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();
}
} } |
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.
|
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);
} |
| 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;
|