summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-10-26 19:02:14 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-10-26 19:10:20 (GMT)
commitadab99b2c73da8d9e0e1c6f72d55deaddb47b8d4 (patch)
treea2c991171f072f5103e200c3b8a3647b02acb567
parent9195089b81bd1f47b7864aa62b833a67703f84a7 (diff)
downloadxamarin-forms-adab99b2c73da8d9e0e1c6f72d55deaddb47b8d4.zip
xamarin-forms-adab99b2c73da8d9e0e1c6f72d55deaddb47b8d4.tar.gz
xamarin-forms-adab99b2c73da8d9e0e1c6f72d55deaddb47b8d4.tar.bz2
[Win] Toolbar placement works with initial value (#488)
* Defer UpdateToolbarPlacement until CommandBar is in the control hierarchy * Cleanup
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/WindowsSpecific/Page.cs2
-rw-r--r--Xamarin.Forms.Platform.UAP/MasterDetailControl.cs7
-rw-r--r--Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs8
-rw-r--r--Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs8
4 files changed, 22 insertions, 3 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/WindowsSpecific/Page.cs b/Xamarin.Forms.Core/PlatformConfiguration/WindowsSpecific/Page.cs
index 59e53b5..fd9503b 100644
--- a/Xamarin.Forms.Core/PlatformConfiguration/WindowsSpecific/Page.cs
+++ b/Xamarin.Forms.Core/PlatformConfiguration/WindowsSpecific/Page.cs
@@ -14,7 +14,7 @@ namespace Xamarin.Forms.PlatformConfiguration.WindowsSpecific
public static readonly BindableProperty ToolbarPlacementProperty =
BindableProperty.CreateAttached("ToolbarPlacement", typeof(ToolbarPlacement),
- typeof(Page), ToolbarPlacement.Default);
+ typeof(FormsElement), ToolbarPlacement.Default);
public static ToolbarPlacement GetToolbarPlacement(BindableObject element)
{
diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
index 51f737f..dddd0ba 100644
--- a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
+++ b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
@@ -239,6 +239,13 @@ namespace Xamarin.Forms.Platform.UWP
_bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
_topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border;
+ if (_commandBar != null && _bottomCommandBarArea != null && _topCommandBarArea != null)
+ {
+ // We have to wait for the command bar to load so that it'll be in the control hierarchy
+ // otherwise we can't properly move it to wherever the toolbar is supposed to be
+ _commandBar.Loaded += (sender, args) => UpdateToolbarPlacement();
+ }
+
UpdateToolbarPlacement();
UpdateMode();
diff --git a/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs b/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
index b06acb1..68586ab 100644
--- a/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
+++ b/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
@@ -77,7 +77,13 @@ namespace Xamarin.Forms.Platform.WinRT
#if WINDOWS_UWP
_bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
_topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border;
- UpdateToolbarPlacement();
+
+ if (_commandBar != null && _bottomCommandBarArea != null && _topCommandBarArea != null)
+ {
+ // We have to wait for the command bar to load so that it'll be in the control hierarchy
+ // otherwise we can't properly move it to wherever the toolbar is supposed to be
+ _commandBar.Loaded += (sender, args) => UpdateToolbarPlacement();
+ }
#endif
TaskCompletionSource<CommandBar> tcs = _commandBarTcs;
diff --git a/Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs b/Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs
index 7be51c0..a57b674 100644
--- a/Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs
+++ b/Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs
@@ -150,7 +150,13 @@ namespace Xamarin.Forms.Platform.WinRT
#if WINDOWS_UWP
_bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
_topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border;
- UpdateToolbarPlacement();
+
+ if (_commandBar != null && _bottomCommandBarArea != null && _topCommandBarArea != null)
+ {
+ // We have to wait for the command bar to load so that it'll be in the control hierarchy
+ // otherwise we can't properly move it to wherever the toolbar is supposed to be
+ _commandBar.Loaded += (sender, args) => UpdateToolbarPlacement();
+ }
#endif
TaskCompletionSource<CommandBar> tcs = _commandBarTcs;