diff --git a/src/Controls/src/Core/ContentView.cs b/src/Controls/src/Core/ContentView.cs
index ee59c4ad46f4..672d9f247542 100644
--- a/src/Controls/src/Core/ContentView.cs
+++ b/src/Controls/src/Core/ContentView.cs
@@ -5,7 +5,7 @@ namespace Microsoft.Maui.Controls
{
///
[ContentProperty("Content")]
- public class ContentView : TemplatedView, IContentView
+ public partial class ContentView : TemplatedView
{
///
public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentView), null, propertyChanged: TemplateUtilities.OnContentChanged);
@@ -17,9 +17,6 @@ public View Content
set { SetValue(ContentProperty, value); }
}
- object IContentView.Content => Content;
- IView IContentView.PresentedContent => ((this as IControlTemplated).TemplateRoot as IView) ?? Content;
-
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
diff --git a/src/Controls/src/Core/HandlerImpl/ContentView/ContentView.Impl.cs b/src/Controls/src/Core/HandlerImpl/ContentView/ContentView.Impl.cs
new file mode 100644
index 000000000000..4c44965267a4
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/ContentView/ContentView.Impl.cs
@@ -0,0 +1,14 @@
+namespace Microsoft.Maui.Controls
+{
+ public partial class ContentView : IContentView
+ {
+ object IContentView.Content => Content;
+ IView IContentView.PresentedContent => ((this as IControlTemplated).TemplateRoot as IView) ?? Content;
+
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ Handler?.UpdateValue(nameof(Content));
+ }
+ }
+}
diff --git a/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Android.cs
new file mode 100644
index 000000000000..068f2eac7738
--- /dev/null
+++ b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Android.cs
@@ -0,0 +1,21 @@
+using Microsoft.Maui.Handlers;
+using Microsoft.Maui.Platform;
+
+namespace Microsoft.Maui.DeviceTests
+{
+ public partial class ContentViewTests
+ {
+ static int GetChildCount(ContentViewHandler contentViewHandler)
+ {
+ return contentViewHandler.PlatformView.ChildCount;
+ }
+
+ static int GetContentChildCount(ContentViewHandler contentViewHandler)
+ {
+ if (contentViewHandler.PlatformView.GetChildAt(0) is LayoutViewGroup childLayoutViewGroup)
+ return childLayoutViewGroup.ChildCount;
+ else
+ return 0;
+ }
+ }
+}
diff --git a/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Windows.cs
new file mode 100644
index 000000000000..2e32a119dae1
--- /dev/null
+++ b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.Windows.cs
@@ -0,0 +1,21 @@
+using Microsoft.Maui.Handlers;
+using Microsoft.Maui.Platform;
+
+namespace Microsoft.Maui.DeviceTests
+{
+ public partial class ContentViewTests
+ {
+ static int GetChildCount(ContentViewHandler contentViewHandler)
+ {
+ return contentViewHandler.PlatformView.Children.Count;
+ }
+
+ static int GetContentChildCount(ContentViewHandler contentViewHandler)
+ {
+ if (contentViewHandler.PlatformView.Children[0] is LayoutPanel childLayoutPanel)
+ return childLayoutPanel.Children.Count;
+ else
+ return 0;
+ }
+ }
+}
diff --git a/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.cs b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.cs
new file mode 100644
index 000000000000..0e5b5256f2b5
--- /dev/null
+++ b/src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Handlers;
+using Microsoft.Maui.Hosting;
+using Microsoft.Maui.Platform;
+using Xunit;
+
+namespace Microsoft.Maui.DeviceTests
+{
+ [Category(TestCategory.ContentView)]
+ public partial class ContentViewTests : HandlerTestBase
+ {
+ void SetupBuilder()
+ {
+ EnsureHandlerCreated(builder =>
+ {
+ builder.ConfigureMauiHandlers(handlers =>
+ {
+ handlers.AddHandler