diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MarkupExtension.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MarkupExtension.cs
index 143b21644d93..2eb187fffb7c 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MarkupExtension.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MarkupExtension.cs
@@ -101,4 +101,103 @@ public MainPage()
await test.RunAsync();
}
+
+ [TestMethod]
+ public async Task TestMarkupExtensionWithShadowingFrameworkElementLoading()
+ {
+ var xamlFile = new XamlFile("MainPage.xaml", """
+
+
+ """);
+
+ var test = new Verify.Test(xamlFile)
+ {
+ TestState =
+ {
+ Sources =
+ {
+ """
+ using Microsoft.UI.Xaml;
+ using Microsoft.UI.Xaml.Controls;
+
+ namespace TestRepro
+ {
+ public partial class BasePage : Page
+ {
+ public string Loading => "";
+ }
+
+ public sealed partial class MainPage : BasePage
+ {
+ public MainPage()
+ {
+ this.InitializeComponent();
+ }
+ }
+ }
+ """
+ }
+ }
+ }.AddGeneratedSources();
+
+ await test.RunAsync();
+ }
+
+ [TestMethod]
+ public async Task TestMarkupExtensionWithShadowingWindowActivated()
+ {
+ var xamlFile = new XamlFile("MainWindow.xaml", """
+
+
+
+
+ """);
+
+ var test = new Verify.Test(xamlFile)
+ {
+ TestState =
+ {
+ Sources =
+ {
+ """
+ using Microsoft.UI.Xaml;
+ using Microsoft.UI.Xaml.Controls;
+
+ namespace TestRepro
+ {
+ public partial class BaseWindow : Window
+ {
+ public string Activated => "";
+ }
+
+ public sealed partial class MainWindow : BaseWindow
+ {
+ public MainWindow()
+ {
+ this.InitializeComponent();
+ }
+ }
+ }
+ """
+ }
+ }
+ }.AddGeneratedSources();
+
+ await test.RunAsync();
+ }
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 54c7ca88673d..dd263452a3de 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -266,7 +266,7 @@ private void InitializeComponent()
Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this));
global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner");
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 580c82975ec5..f0729493fa25 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -157,7 +157,7 @@ private void InitializeComponent()
Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this));
global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner");
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 319bfaf24a85..03820a9bd7b7 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -145,7 +145,7 @@ private void InitializeComponent()
Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this));
global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner");
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 2add00bedf88..2bf5ae4c462e 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -120,7 +120,7 @@ private void InitializeComponent()
Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this));
global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner");
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 35d8d8b60e2c..a8cda57d2588 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -108,7 +108,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 03fc77225acc..e7e1b9928652 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -117,7 +117,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.UpdateResources();
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 51629ab748af..9a3a0753c9e7 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -105,7 +105,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 786d3dca7ab7..ea1117eec05b 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -158,7 +158,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_GlobalStaticResources.cs
new file mode 100644
index 000000000000..ad59ff1058b5
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_GlobalStaticResources.cs
@@ -0,0 +1,55 @@
+//
+namespace MyProject
+{
+ ///
+ /// Contains all the static resources defined for the application
+ ///
+ public sealed partial class GlobalStaticResources
+ {
+ static bool _initialized;
+ private static bool _stylesRegistered;
+ private static bool _dictionariesRegistered;
+ internal static global::Uno.UI.Xaml.XamlParseContext __ParseContext_ { get; } = new global::Uno.UI.Xaml.XamlParseContext()
+ {
+ AssemblyName = "TestProject",
+ }
+ ;
+
+ static GlobalStaticResources()
+ {
+ Initialize();
+ }
+ public static void Initialize()
+ {
+ if (!_initialized)
+ {
+ _initialized = true;
+ global::Uno.UI.GlobalStaticResources.Initialize();
+ global::Uno.UI.GlobalStaticResources.RegisterDefaultStyles();
+ global::Uno.UI.GlobalStaticResources.RegisterResourceDictionariesBySource();
+ }
+ }
+ public static void RegisterDefaultStyles()
+ {
+ if(!_stylesRegistered)
+ {
+ _stylesRegistered = true;
+ RegisterDefaultStyles_MainPage_d6cd66944958ced0c513e0a04797b51d();
+ }
+ }
+ // Register ResourceDictionaries using ms-appx:/// syntax, this is called for external resources
+ public static void RegisterResourceDictionariesBySource()
+ {
+ if(!_dictionariesRegistered)
+ {
+ _dictionariesRegistered = true;
+ }
+ }
+ // Register ResourceDictionaries using ms-resource:/// syntax, this is called for local resources
+ internal static void RegisterResourceDictionariesBySourceLocal()
+ {
+ }
+ static partial void RegisterDefaultStyles_MainPage_d6cd66944958ced0c513e0a04797b51d();
+
+ }
+}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_LocalizationResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_LocalizationResources.cs
new file mode 100644
index 000000000000..115ce87c0105
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_LocalizationResources.cs
@@ -0,0 +1,2 @@
+//
+[assembly: global::System.Reflection.AssemblyMetadata("UnoHasLocalizationResources", "False")]
\ No newline at end of file
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
new file mode 100644
index 000000000000..61bbbb0b32fb
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -0,0 +1,143 @@
+//
+#pragma warning disable CS0114
+#pragma warning disable CS0108
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using Uno.UI;
+using Uno.UI.Xaml;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Documents;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Media.Animation;
+using Microsoft.UI.Xaml.Shapes;
+using Windows.UI.Text;
+using Uno.Extensions;
+using Uno;
+using Uno.UI.Helpers;
+using Uno.UI.Helpers.Xaml;
+using MyProject;
+
+#if __ANDROID__
+using _View = Android.Views.View;
+#elif __IOS__
+using _View = UIKit.UIView;
+#elif __MACOS__
+using _View = AppKit.NSView;
+#else
+using _View = Microsoft.UI.Xaml.UIElement;
+#endif
+
+namespace TestRepro
+{
+ partial class MainPage : global::TestRepro.BasePage
+ {
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/";
+ private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
+ private void InitializeComponent()
+ {
+ NameScope.SetNameScope(this, __nameScope);
+ var __that = this;
+ base.IsParsing = true;
+ // Source 0\MainPage.xaml (Line 1:2)
+ ;
+
+ this
+ .GenericApply(((c0) =>
+ {
+ // Source 0\MainPage.xaml (Line 1:2)
+
+ // WARNING Property c0.base does not exist on {using:TestRepro}BasePage, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
+ }
+ ))
+ .GenericApply(((c1) =>
+ {
+ /* _isTopLevelDictionary:False */
+ __that._component_0 = c1;
+ // Class TestRepro.MainPage
+ global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c1, global::TestRepro.BasePage.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_);
+ global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d);
+ c1.CreationComplete();
+ }
+ ))
+ ;
+ OnInitializeCompleted();
+
+ Bindings = new MainPage_Bindings(this);
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
+ {
+ __that.Bindings.UpdateResources();
+ }
+ ;
+ }
+ partial void OnInitializeCompleted();
+ private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true);
+ private global::TestRepro.BasePage _component_0
+ {
+ get
+ {
+ return (global::TestRepro.BasePage)_component_0_Holder.Instance;
+ }
+ set
+ {
+ _component_0_Holder.Instance = value;
+ }
+ }
+ private interface IMainPage_Bindings
+ {
+ void Initialize();
+ void Update();
+ void UpdateResources();
+ void StopTracking();
+ void NotifyXLoad(string name);
+ }
+ #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used.
+ private IMainPage_Bindings Bindings;
+ #pragma warning restore 0169
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ private class MainPage_Bindings : IMainPage_Bindings
+ {
+ #if UNO_HAS_UIELEMENT_IMPLICIT_PINNING
+ private global::System.WeakReference _ownerReference;
+ private global::TestRepro.MainPage Owner { get => (global::TestRepro.MainPage)_ownerReference?.Target; set => _ownerReference = new global::System.WeakReference(value); }
+ #else
+ private global::TestRepro.MainPage Owner { get; set; }
+ #endif
+ public MainPage_Bindings(global::TestRepro.MainPage owner)
+ {
+ Owner = owner;
+ }
+ void IMainPage_Bindings.NotifyXLoad(string name)
+ {
+ }
+ void IMainPage_Bindings.Initialize()
+ {
+ }
+ void IMainPage_Bindings.Update()
+ {
+ var owner = Owner;
+ }
+ void IMainPage_Bindings.UpdateResources()
+ {
+ var owner = Owner;
+ owner._component_0.UpdateResourceBindings(resourceContextProvider: null);
+ }
+ void IMainPage_Bindings.StopTracking()
+ {
+ }
+ }
+ }
+}
+namespace MyProject
+{
+ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions
+ {
+ }
+}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_GlobalStaticResources.cs
new file mode 100644
index 000000000000..52a9c3931f1e
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_GlobalStaticResources.cs
@@ -0,0 +1,55 @@
+//
+namespace MyProject
+{
+ ///
+ /// Contains all the static resources defined for the application
+ ///
+ public sealed partial class GlobalStaticResources
+ {
+ static bool _initialized;
+ private static bool _stylesRegistered;
+ private static bool _dictionariesRegistered;
+ internal static global::Uno.UI.Xaml.XamlParseContext __ParseContext_ { get; } = new global::Uno.UI.Xaml.XamlParseContext()
+ {
+ AssemblyName = "TestProject",
+ }
+ ;
+
+ static GlobalStaticResources()
+ {
+ Initialize();
+ }
+ public static void Initialize()
+ {
+ if (!_initialized)
+ {
+ _initialized = true;
+ global::Uno.UI.GlobalStaticResources.Initialize();
+ global::Uno.UI.GlobalStaticResources.RegisterDefaultStyles();
+ global::Uno.UI.GlobalStaticResources.RegisterResourceDictionariesBySource();
+ }
+ }
+ public static void RegisterDefaultStyles()
+ {
+ if(!_stylesRegistered)
+ {
+ _stylesRegistered = true;
+ RegisterDefaultStyles_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b();
+ }
+ }
+ // Register ResourceDictionaries using ms-appx:/// syntax, this is called for external resources
+ public static void RegisterResourceDictionariesBySource()
+ {
+ if(!_dictionariesRegistered)
+ {
+ _dictionariesRegistered = true;
+ }
+ }
+ // Register ResourceDictionaries using ms-resource:/// syntax, this is called for local resources
+ internal static void RegisterResourceDictionariesBySourceLocal()
+ {
+ }
+ static partial void RegisterDefaultStyles_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b();
+
+ }
+}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_LocalizationResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_LocalizationResources.cs
new file mode 100644
index 000000000000..115ce87c0105
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_LocalizationResources.cs
@@ -0,0 +1,2 @@
+//
+[assembly: global::System.Reflection.AssemblyMetadata("UnoHasLocalizationResources", "False")]
\ No newline at end of file
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs
new file mode 100644
index 000000000000..b39bde13ce4f
--- /dev/null
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs
@@ -0,0 +1,162 @@
+//
+#pragma warning disable CS0114
+#pragma warning disable CS0108
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using Uno.UI;
+using Uno.UI.Xaml;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Documents;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Media.Animation;
+using Microsoft.UI.Xaml.Shapes;
+using Windows.UI.Text;
+using Uno.Extensions;
+using Uno;
+using Uno.UI.Helpers;
+using Uno.UI.Helpers.Xaml;
+using MyProject;
+
+#if __ANDROID__
+using _View = Android.Views.View;
+#elif __IOS__
+using _View = UIKit.UIView;
+#elif __MACOS__
+using _View = AppKit.NSView;
+#else
+using _View = Microsoft.UI.Xaml.UIElement;
+#endif
+
+namespace TestRepro
+{
+ partial class MainWindow : global::TestRepro.BaseWindow
+ {
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private const string __baseUri_prefix_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b = "ms-appx:///TestProject/";
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ private const string __baseUri_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b = "ms-appx:///TestProject/";
+ private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();
+ private void InitializeComponent()
+ {
+ var __that = this;
+ // Source 0\MainWindow.xaml (Line 1:2)
+ base.Content =
+ new global::Microsoft.UI.Xaml.Controls.Page
+ {
+ IsParsing = true,
+ // Source 0\MainWindow.xaml (Line 10:3)
+ }
+ .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler0)(c0 =>
+ {
+ /* _isTopLevelDictionary:False */
+ __that._component_0 = c0;
+ global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c0, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_);
+ global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b);
+ c0.CreationComplete();
+ }
+ ))
+ ;
+
+ this
+ .GenericApply(((c1) =>
+ {
+ // Source 0\MainWindow.xaml (Line 1:2)
+
+ // WARNING Property c1.base does not exist on {using:TestRepro}BaseWindow, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
+ }
+ ))
+ .GenericApply(((c2) =>
+ {
+ // Class TestRepro.MainWindow
+ }
+ ))
+ ;
+ if (__that.Content != null)
+ {
+ NameScope.SetNameScope(__that.Content, __nameScope);
+ }
+ OnInitializeCompleted();
+
+ Bindings = new MainWindow_Bindings(this);
+ ((global::Microsoft.UI.Xaml.Window)this).Activated += (s, e) =>
+ {
+ __that.Bindings.UpdateResources();
+ }
+ ;
+ }
+ partial void OnInitializeCompleted();
+ private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true);
+ private global::Microsoft.UI.Xaml.Controls.Page _component_0
+ {
+ get
+ {
+ return (global::Microsoft.UI.Xaml.Controls.Page)_component_0_Holder.Instance;
+ }
+ set
+ {
+ _component_0_Holder.Instance = value;
+ }
+ }
+ private interface IMainWindow_Bindings
+ {
+ void Initialize();
+ void Update();
+ void UpdateResources();
+ void StopTracking();
+ void NotifyXLoad(string name);
+ }
+ #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used.
+ private IMainWindow_Bindings Bindings;
+ #pragma warning restore 0169
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ private class MainWindow_Bindings : IMainWindow_Bindings
+ {
+ #if UNO_HAS_UIELEMENT_IMPLICIT_PINNING
+ private global::System.WeakReference _ownerReference;
+ private global::TestRepro.MainWindow Owner { get => (global::TestRepro.MainWindow)_ownerReference?.Target; set => _ownerReference = new global::System.WeakReference(value); }
+ #else
+ private global::TestRepro.MainWindow Owner { get; set; }
+ #endif
+ public MainWindow_Bindings(global::TestRepro.MainWindow owner)
+ {
+ Owner = owner;
+ }
+ void IMainWindow_Bindings.NotifyXLoad(string name)
+ {
+ }
+ void IMainWindow_Bindings.Initialize()
+ {
+ }
+ void IMainWindow_Bindings.Update()
+ {
+ var owner = Owner;
+ }
+ void IMainWindow_Bindings.UpdateResources()
+ {
+ var owner = Owner;
+ owner._component_0.UpdateResourceBindings(resourceContextProvider: null);
+ }
+ void IMainWindow_Bindings.StopTracking()
+ {
+ }
+ }
+ }
+}
+namespace MyProject
+{
+ static class MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions
+ {
+ public delegate void XamlApplyHandler0(global::Microsoft.UI.Xaml.Controls.Page instance);
+ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ public static global::Microsoft.UI.Xaml.Controls.Page MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler0 handler)
+ {
+ handler(instance);
+ return instance;
+ }
+ }
+}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 1240075ea24b..5a9c9ca43324 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -204,7 +204,7 @@ void _component_1_materializing(object sender)
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 5ba188311199..20dfc191585a 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -118,7 +118,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.UpdateResources();
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index f077439704e9..3c3a8c59ae5b 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -241,7 +241,7 @@ void _component_1_materializing(object sender)
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 9e9d46494746..f6e23a5a2a9c 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -108,7 +108,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index 9c04fd3d92cb..342c0df83f4a 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -205,7 +205,7 @@ void _component_1_materializing(object sender)
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index f3f85ce0a27b..62ba5564cffb 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -149,7 +149,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index f3f85ce0a27b..62ba5564cffb 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -149,7 +149,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index f3f85ce0a27b..62ba5564cffb 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -149,7 +149,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
index f3f85ce0a27b..62ba5564cffb 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs
@@ -149,7 +149,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new MainPage_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.Update();
__that.Bindings.UpdateResources();
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs
index 7c7b116e61a9..b365d60b3226 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs
@@ -127,7 +127,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new Binding_Xaml_Object_With_Common_Properties_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.UpdateResources();
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs
index a83335cee1f8..05bddbe9f9ce 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs
@@ -119,7 +119,7 @@ private void InitializeComponent()
OnInitializeCompleted();
Bindings = new Binding_Xaml_Object_With_Xaml_Object_Properties_Bindings(this);
- Loading += (s, e) =>
+ ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>
{
__that.Bindings.UpdateResources();
}
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
index 333dca9df08a..dad30c70eb21 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
@@ -1042,9 +1042,11 @@ private void BuildCompiledBindingsInitializer(IndentedStringBuilder writer, INam
writer.AppendLineIndented($"global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, \"owner\", __that);");
}
+ // Casting to FrameworkElement or Window is important to avoid issues when there
+ // is a member named Loading or Activated that shadows the ones from FrameworkElement/Window
var eventSubscription = isFrameworkElement
- ? "Loading += (s, e) =>"
- : "Activated += (s, e) =>";
+ ? "((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>"
+ : "((global::Microsoft.UI.Xaml.Window)this).Activated += (s, e) =>";
using (writer.BlockInvariant(eventSubscription))
{