ShowDialog together with hiding appbar placement issue

Topics: Bugs
Oct 24, 2012 at 12:42 PM
Edited Oct 24, 2012 at 12:43 PM

When appbar is hidden together with ShowDialog execution then from time to time (its appbar render timing related issue) there is blank gap below show dialog because dialog size that is defined in ArrangePlacement takes wrong screen size because app bar is currently hiding. My proposition is to also subscribe to Page SizeChanged event in Open method so it should look like this

 

            public void Open() {
                if(isOpen)
                    return;
                isOpen = true;

                if(currentPage.ApplicationBar != null) {
                    DisableAppBar();
                }

                ArrangePlacement();


                currentPage.BackKeyPress += CurrentPageBackKeyPress;
                currentPage.OrientationChanged += CurrentPageOrientationChanged;
                currentPage.SizeChanged += CurrentPageOnSizeChanged;

                hostPopup.IsOpen = true;
            }
            private void CurrentPageOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
            {
                ArrangePlacement();
            }

What do you think?

Oct 24, 2012 at 1:26 PM

I think it's even better approach.

            public void Open() {
                if (currentPage.ApplicationBar == null || currentPage.ApplicationBar.IsVisible)
                {
                    if (isOpen)
                        return;
                    isOpen = true;

                    if (currentPage.ApplicationBar != null)
                    {
                        DisableAppBar();
                    }

                    ArrangePlacement();

                    currentPage.BackKeyPress += CurrentPageBackKeyPress;
                    //currentPage.OrientationChanged += CurrentPageOrientationChanged;
                    currentPage.SizeChanged += CurrentPageOnSizeChanged;

                    hostPopup.IsOpen = true;
                }
                else
                {
                    currentPage.SizeChanged += CurrentPageOnSizeChanged;
                }
            }

            private void CurrentPageOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
            {
                var localIsOpen = isOpen;
                if (!localIsOpen)
                {
                    isOpen = true;

                    if (currentPage.ApplicationBar != null)
                    {
                        DisableAppBar();
                    }
                }

                hostPopup.HorizontalOffset = 0;
                hostPopup.VerticalOffset = 0;
                ArrangePlacement();

                if (!localIsOpen)
                {
                    currentPage.BackKeyPress += CurrentPageBackKeyPress;

                    hostPopup.IsOpen = true;    
                }
            }