summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorPaul DiPietro <paul.dipietro@me.com>2016-04-12 11:15:21 -0700
committerJason Smith <jason.smith@xamarin.com>2016-04-12 11:15:21 -0700
commit76c8c57fb30621272e19d493787836ed8c322b9d (patch)
tree4052edc8d289daf5f9982948f02f0a4d17fd349a /Xamarin.Forms.Platform.WinRT
parentc92297047c01112fd4a6e7695a40acb274fdf7a7 (diff)
downloadxamarin-forms-76c8c57fb30621272e19d493787836ed8c322b9d.tar.gz
xamarin-forms-76c8c57fb30621272e19d493787836ed8c322b9d.tar.bz2
xamarin-forms-76c8c57fb30621272e19d493787836ed8c322b9d.zip
[UWP] Adjust bounds for ContentPage when by itself (#61)
In a scenario where there is a ContentPage by itself, things like labels ran beneath the StatusBar in landscape mode. This is presumably because the page was assuming there to be a TitleBar and calculating the bounds based on that fact; by checking for its visibility and adjusting the bounds as necessary it allows for correct alignment.
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/Platform.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/Platform.cs b/Xamarin.Forms.Platform.WinRT/Platform.cs
index dbef5f7d..012dd2c4 100644
--- a/Xamarin.Forms.Platform.WinRT/Platform.cs
+++ b/Xamarin.Forms.Platform.WinRT/Platform.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.Popups;
using Windows.UI.Xaml;
@@ -421,9 +422,19 @@ namespace Xamarin.Forms.Platform.WinRT
StatusBar statusBar = StatusBar.GetForCurrentView();
bool landscape = Device.Info.CurrentOrientation.IsLandscape();
+ bool titleBar = CoreApplication.GetCurrentView().TitleBar.IsVisible;
double offset = landscape ? statusBar.OccludedRect.Width : statusBar.OccludedRect.Height;
_bounds = new Rectangle(0, 0, _page.ActualWidth - (landscape ? offset : 0), _page.ActualHeight - (landscape ? 0 : offset));
+
+ // Even if the MainPage is a ContentPage not inside of a NavigationPage, the calculated bounds
+ // assume the TitleBar is there even if it isn't visible. When UpdatePageSizes is called,
+ // _container.ActualWidth is correct because it's aware that the TitleBar isn't there, but the
+ // bounds aren't, and things can subsequently run under the StatusBar.
+ if (!titleBar)
+ {
+ _bounds.Width -= (_bounds.Width - _container.ActualWidth);
+ }
}
#endif
}