diff --git a/build/ios-uitest-run.sh b/build/ios-uitest-run.sh
index d4b41e3baa14..6bb53b2c4a41 100755
--- a/build/ios-uitest-run.sh
+++ b/build/ios-uitest-run.sh
@@ -43,6 +43,7 @@ else
namespace = 'SamplesApp.UITests.Microsoft_UI_Xaml_Controls.NumberBoxTests' or \
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.TextBoxTests' or \
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.PivotTests' or \
+ namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.CommandBarTests' or \
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.ComboBoxTests' or \
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Media_Animation.DoubleAnimation_Tests' or \
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.BorderTests'
diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.NativeCommandBar.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.NativeCommandBar.cs
index bf4cd20b633c..d120ec3c3afe 100644
--- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.NativeCommandBar.cs
+++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.NativeCommandBar.cs
@@ -9,7 +9,7 @@
using Uno.UITest.Helpers;
using Uno.UITest.Helpers.Queries;
-namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.ComboBoxTests
+namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.CommandBarTests
{
[TestFixture]
public partial class NativeCommandBar_Tests : SampleControlUITestBase
@@ -62,5 +62,27 @@ public void NativeCommandBar_Content_Alignment_Automated()
TakeScreenshot("Left");
}
+
+ [Test]
+ [AutoRetry]
+ public void When_TextBlock_Centred_Native_Frame()
+ {
+ Run("UITests.Windows_UI_Xaml_Controls.CommandBar.CommandBar_Native_Frame");
+
+ _app.WaitForElement("NavigateInitialButton");
+ _app.FastTap("NavigateInitialButton");
+
+ _app.WaitForElement("NavigateDetailButton");
+ _app.FastTap("NavigateDetailButton");
+
+ _app.WaitForElement("NavigateBackButton");
+ _app.FastTap("NavigateBackButton");
+
+ _app.WaitForElement("CommandBarTitleText");
+ var rect = _app.GetRect("CommandBarTitleText");
+
+ Assert.Greater(rect.Height, 1);
+
+ }
}
}
diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.XamlCommandBar.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.XamlCommandBar.cs
index df86393d16df..b224b9b3eab7 100644
--- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.XamlCommandBar.cs
+++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.XamlCommandBar.cs
@@ -9,7 +9,7 @@
using Uno.UITest.Helpers;
using Uno.UITest.Helpers.Queries;
-namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.ComboBoxTests
+namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.CommandBarTests
{
[TestFixture]
public partial class XamlCommandBar_Tests : SampleControlUITestBase
diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
index 657e920316bf..5c647627d475 100644
--- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
+++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
@@ -545,6 +545,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -557,6 +561,14 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -3398,6 +3410,9 @@
ComboBox_VisibleBounds.xaml
+
+ CommandBar_Native_Frame.xaml
+
CommandBar_Native_With_Content.xaml
@@ -3410,6 +3425,12 @@
BitmapIcon_Generic.xaml
+
+ Page_Detail.xaml
+
+
+ Page_With_CommandBar_TextBlock.xaml
+
ContentControlNoTemplateNoContent.xaml
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml
new file mode 100644
index 000000000000..1ab840391396
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml.cs
new file mode 100644
index 000000000000..34be78a24073
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/CommandBar_Native_Frame.xaml.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using UITests.Windows_UI_Xaml_Controls.CommandBar.Native_Frame;
+using Uno.UI.Samples.Controls;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
+
+namespace UITests.Windows_UI_Xaml_Controls.CommandBar
+{
+ [Sample]
+ public sealed partial class CommandBar_Native_Frame : UserControl
+ {
+ public CommandBar_Native_Frame()
+ {
+ this.InitializeComponent();
+ }
+
+ private void Navigate_Initial(object sender, RoutedEventArgs args)
+ {
+ hostFrame.Navigate(typeof(Page_With_CommandBar_TextBlock));
+ }
+ }
+}
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml
new file mode 100644
index 000000000000..911a4cdb9ef4
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml.cs
new file mode 100644
index 000000000000..4113cf08dc70
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_Detail.xaml.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace UITests.Windows_UI_Xaml_Controls.CommandBar.Native_Frame
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Page_Detail : Page
+ {
+ public Page_Detail()
+ {
+ this.InitializeComponent();
+ }
+
+ private void Navigate_Back(object sender, RoutedEventArgs args) => Frame.GoBack();
+
+ }
+}
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml
new file mode 100644
index 000000000000..8f73d2d6fe7a
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml.cs
new file mode 100644
index 000000000000..56346ecc98af
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/Native_Frame/Page_With_CommandBar_TextBlock.xaml.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace UITests.Windows_UI_Xaml_Controls.CommandBar.Native_Frame
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Page_With_CommandBar_TextBlock : Page
+ {
+ public Page_With_CommandBar_TextBlock()
+ {
+ this.InitializeComponent();
+ }
+
+ private void Navigate_Onward(object sender, RoutedEventArgs args)
+ {
+ Frame.Navigate(typeof(Page_Detail));
+ }
+
+ }
+}
diff --git a/src/Uno.UI/Controls/CommandBarNavigationItemRenderer.iOS.cs b/src/Uno.UI/Controls/CommandBarNavigationItemRenderer.iOS.cs
index 86fc03e2bba0..98a77abc985c 100644
--- a/src/Uno.UI/Controls/CommandBarNavigationItemRenderer.iOS.cs
+++ b/src/Uno.UI/Controls/CommandBarNavigationItemRenderer.iOS.cs
@@ -136,6 +136,8 @@ internal partial class TitleView : Border
{
private bool _blockReentrantMeasure;
private Size _childSize;
+ private Size? _lastAvailableSize;
+
public TitleView()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
@@ -167,6 +169,8 @@ protected override Size MeasureOverride(Size availableSize)
{
_blockReentrantMeasure = true;
+ _lastAvailableSize = availableSize;
+
// By default, iOS will horizontally center the TitleView inside the UINavigationBar,
// ignoring the size of the left and right buttons.
@@ -207,7 +211,10 @@ public override CGRect Frame
get { return base.Frame; }
set
{
- if (!UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
+ if (!UIDevice.CurrentDevice.CheckSystemVersion(11, 0)
+ // iOS likes to mix things up by calling SizeThatFits with zero Height for no apparent reason (eg when navigating back to a page). When
+ // this happens, we need to remeasure with the correct size to ensure children are laid out correctly.
+ || (_lastAvailableSize?.Height == 0 && value.Height != 0))
{
// This allows text trimming when there are more AppBarButtons
var availableSize = value.Size;
@@ -218,4 +225,4 @@ public override CGRect Frame
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Uno.UI/Extensions/UIViewExtensions.iOSmacOS.cs b/src/Uno.UI/Extensions/UIViewExtensions.iOSmacOS.cs
index 2746ddbfb583..3c42974e10de 100644
--- a/src/Uno.UI/Extensions/UIViewExtensions.iOSmacOS.cs
+++ b/src/Uno.UI/Extensions/UIViewExtensions.iOSmacOS.cs
@@ -14,6 +14,7 @@
using Uno.Logging;
using Windows.UI.Core;
using Uno.UI.Controls;
+using Windows.UI.Xaml.Controls;
#if XAMARIN_IOS_UNIFIED
using Foundation;
@@ -594,6 +595,7 @@ StringBuilder AppendView(_View innerView)
.Append($" {(innerView.Hidden ? "Hidden" : "Visible")}")
#endif
.Append(uiElement?.NeedsClipToSlot ?? false ? " CLIPPED_TO_SLOT" : "")
+ .Append(innerView is TextBlock textBlock ? $" Text=\"{textBlock.Text}\"" : "")
.AppendLine();
}
}