diff --git a/src/SamplesApp/SamplesApp.Droid/SamplesApp.Droid.csproj b/src/SamplesApp/SamplesApp.Droid/SamplesApp.Droid.csproj
index 6fc77940a7a3..712f900df0d0 100644
--- a/src/SamplesApp/SamplesApp.Droid/SamplesApp.Droid.csproj
+++ b/src/SamplesApp/SamplesApp.Droid/SamplesApp.Droid.csproj
@@ -21,8 +21,6 @@
..\SamplesApp.Shared\Strings
false
-
- false
true
diff --git a/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj b/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj
index 3874ac975c39..46fc660c5fb8 100644
--- a/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj
+++ b/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj
@@ -7,9 +7,6 @@
$(DefineConstants);__WASM__;HAS_UNO
NU1701,CS1998
7.3
-
- false
-
true
true
diff --git a/src/SamplesApp/SamplesApp.iOS/SamplesApp.iOS.csproj b/src/SamplesApp/SamplesApp.iOS/SamplesApp.iOS.csproj
index d421f9b5bd47..749ae17cdb86 100644
--- a/src/SamplesApp/SamplesApp.iOS/SamplesApp.iOS.csproj
+++ b/src/SamplesApp/SamplesApp.iOS/SamplesApp.iOS.csproj
@@ -13,8 +13,6 @@
true
..\SamplesApp.Shared\Strings
-
- false
true
@@ -179,4 +177,4 @@
-
\ No newline at end of file
+
diff --git a/src/SamplesApp/SamplesApp.macOS/SamplesApp.macOS.csproj b/src/SamplesApp/SamplesApp.macOS/SamplesApp.macOS.csproj
index 60a5c3dd6601..767fef1ff458 100644
--- a/src/SamplesApp/SamplesApp.macOS/SamplesApp.macOS.csproj
+++ b/src/SamplesApp/SamplesApp.macOS/SamplesApp.macOS.csproj
@@ -11,7 +11,6 @@
v2.0
Xamarin.Mac
Resources
- false
true
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ComplexSetters_Automated.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ComplexSetters_Automated.xaml
index a6c39c83cdff..a12d22ba4b77 100644
--- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ComplexSetters_Automated.xaml
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/VisualStateTests/VisualState_ComplexSetters_Automated.xaml
@@ -11,30 +11,30 @@
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ScrollViewerTests/ScrollViewer_UpdatesMode.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ScrollViewerTests/ScrollViewer_UpdatesMode.xaml
index ffea2768fe90..4ac761b32d04 100644
--- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ScrollViewerTests/ScrollViewer_UpdatesMode.xaml
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ScrollViewerTests/ScrollViewer_UpdatesMode.xaml
@@ -6,7 +6,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xamarin="http://platform.uno/xamarin"
- xmlns:not_xamarin="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
mc:Ignorable="d xamarin"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@@ -52,6 +51,4 @@
-
-
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
index 42e21f95997f..3eb2811e6641 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
@@ -41,7 +41,7 @@ internal partial class XamlCodeGeneration
// Determines if the source generator will skip the inclusion of UseControls in the
// visual tree. See https://github.com/unoplatform/uno/issues/61
- private bool _skipUserControlsInVisualTree = true;
+ private bool _skipUserControlsInVisualTree = false;
#pragma warning disable 649 // Unused member
private readonly bool _forceGeneration;
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
index 3b5f42bb2250..45b26048ddd7 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
@@ -299,7 +299,7 @@ private string InnerGenerateFile()
using (writer.BlockInvariant("public partial class {0} : {1}", _className.className, controlBaseType.ToDisplayString()))
{
- var isDirectUserControlChild = IsUserControl(topLevelControl.Type, checkInheritance: false);
+ var isDirectUserControlChild = _skipUserControlsInVisualTree && IsUserControl(topLevelControl.Type, checkInheritance: false);
using (Scope("{0}{1}".InvariantCultureFormat(_className.ns.Replace(".", ""), _className.className)))
{
@@ -701,7 +701,7 @@ private string BuildControlInitializerDeclaration(string className, XamlObjectDe
{
return "protected override void InitializeComponent()";
}
- else if (IsUserControl(topLevelControl.Type, checkInheritance: false))
+ else if (_skipUserControlsInVisualTree && IsUserControl(topLevelControl.Type, checkInheritance: false))
{
string contentTypeDisplayString = GetImplicitChildTypeDisplayString(topLevelControl);
@@ -1706,7 +1706,7 @@ private bool BuildProperties(IIndentedStringBuilder writer, XamlObjectDefinition
}
}
}
- else if (IsUserControl(topLevelControl.Type))
+ else if (_skipUserControlsInVisualTree && IsUserControl(topLevelControl.Type))
{
if (implicitContentChild.Objects.Any())
{
@@ -1929,7 +1929,7 @@ implicitContentChild.Value is string implicitValue
return true;
}
- else if (returnsContent && IsUserControl(topLevelControl.Type))
+ else if (returnsContent && _skipUserControlsInVisualTree && IsUserControl(topLevelControl.Type))
{
writer.AppendFormatInvariant(XamlConstants.Types.IFrameworkElement + " content = null");
}
diff --git a/src/Uno.UI.Tests/Uno.UI.Tests.csproj b/src/Uno.UI.Tests/Uno.UI.Tests.csproj
index b1a97afa6417..64525f463928 100644
--- a/src/Uno.UI.Tests/Uno.UI.Tests.csproj
+++ b/src/Uno.UI.Tests/Uno.UI.Tests.csproj
@@ -27,8 +27,8 @@
-
-
+
+
5.10.3
@@ -94,6 +94,7 @@
+
diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/Given_UserControl.cs b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/Given_UserControl.cs
new file mode 100644
index 000000000000..b0b369a53316
--- /dev/null
+++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/Given_UserControl.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Uno.UI.Tests.Windows_UI_XAML_Controls.UserControlTests;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Data;
+
+namespace Uno.UI.Tests.Windows_UI_Xaml_Controls.xLoad
+{
+ [TestClass]
+ public class Given_UserControl
+ {
+ [TestMethod]
+ public void When_UserControl_TopLevel_Binding()
+ {
+ var sut = new UserControl_TopLevelBinding();
+ sut.ForceLoaded();
+
+ var uc01 = sut.FindName("uc01");
+
+ Assert.AreEqual(0, UserControl_TopLevelBinding_AttachedProperty.MyPropertyChangedCount);
+ Assert.AreEqual(0, UserControl_TopLevelBinding_AttachedProperty.GetMyProperty(uc01));
+
+ sut.DataContext = 42;
+
+ Assert.AreEqual(1, UserControl_TopLevelBinding_AttachedProperty.MyPropertyChangedCount);
+ Assert.AreEqual(42, UserControl_TopLevelBinding_AttachedProperty.GetMyProperty(uc01));
+ }
+ }
+}
diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml
new file mode 100644
index 000000000000..e4464f21d23d
--- /dev/null
+++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml.cs b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml.cs
new file mode 100644
index 000000000000..27cc7c724baa
--- /dev/null
+++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding.xaml.cs
@@ -0,0 +1,30 @@
+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 Uno.UI.Tests.Windows_UI_XAML_Controls.UserControlTests
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class UserControl_TopLevelBinding : Page
+ {
+ public UserControl_TopLevelBinding()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml
new file mode 100644
index 000000000000..c07b1430f9fd
--- /dev/null
+++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml.cs b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml.cs
new file mode 100644
index 000000000000..9c40c867da73
--- /dev/null
+++ b/src/Uno.UI.Tests/Windows_UI_XAML_Controls/UserControlTests/UserControl_TopLevelBinding_UserControl.xaml.cs
@@ -0,0 +1,54 @@
+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 Uno.UI.Tests.Windows_UI_XAML_Controls.UserControlTests
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class UserControl_TopLevelBinding_UserControl : UserControl
+ {
+ public UserControl_TopLevelBinding_UserControl()
+ {
+ this.InitializeComponent();
+ }
+ }
+
+ public static class UserControl_TopLevelBinding_AttachedProperty
+ {
+ public static int GetMyProperty(DependencyObject obj)
+ {
+ return (int)obj.GetValue(MyPropertyProperty);
+ }
+
+ public static void SetMyProperty(DependencyObject obj, int value)
+ {
+ obj.SetValue(MyPropertyProperty, value);
+ }
+
+ // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MyPropertyProperty =
+ DependencyProperty.RegisterAttached("MyProperty", typeof(int), typeof(UserControl_TopLevelBinding_AttachedProperty), new PropertyMetadata(0, OnMyPropertyChanged));
+
+ public static int MyPropertyChangedCount { get; private set; }
+
+ private static void OnMyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
+ {
+ MyPropertyChangedCount++;
+ }
+ }
+}