Skip to content

Lazily loaded control (x:Load=false) is missing XamlScope for its resource resolution #23088

Closed

Description

@Xiaoy312

Current behavior 🐛

{StaticResource} on a lazily loaded element or from a lazily loaded subtree
will log a warning when it is initially resolved, as it fails to resolve statically since the xaml-scope is missing/lost
basically only the control itself participate in the resolution, and none of its ancestors.
although, the resource is ultimately resolved via ResourceBinding, it leaves noises(warnings) in the logs

callstack
00 kahua403_StrictXamlCompile.MainPage..ctor.AnonymousMethod__0_0(s, e) Line 9
01 Microsoft.UI.Xaml.FrameworkElement.FindName(name) Line 53
02 Microsoft.UI.Xaml.IFrameworkElementHelper.FindName(e, group, name) Line 236
03 Uno.UI.ViewExtensions.FindLastChild<string, Microsoft.UI.Xaml.IFrameworkElement>(group, param, selector, hasAnyChildren) Line 26
04 Microsoft.UI.Xaml.IFrameworkElementHelper.FindName.AnonymousMethod__2_1(c, name) Line 236
05 Microsoft.UI.Xaml.FrameworkElement.FindName(name) Line 53
06 Microsoft.UI.Xaml.IFrameworkElementHelper.FindName(e, group, name) Line 241
07 Microsoft.UI.Xaml.IFrameworkElementHelper.ConvertFromStubToElement(element, originalRootElement, name) Line 388
08 Microsoft.UI.Xaml.ElementStub.Materialize() Line 180
09 Microsoft.UI.Xaml.ElementStub.MaterializeInner() Line 206
10 Microsoft.UI.Xaml.ElementStub.SwapViews(oldView, newViewProvider) Line 20
11 kahua403_StrictXamlCompile.MainPage.InitializeComponent.AnonymousMethod__0() Line 72
12 Uno.UI.Helpers.Xaml.ApplyExtensions.GenericApply<Microsoft.UI.Xaml.Controls.ContentControl, kahua403_StrictXamlCompile.MainPage, Microsoft.UI.Xaml.NameScope>(instance, arg1, arg2, apply) Line 58
13 kahua403_StrictXamlCompile.MainPage.ApplyTo_PagΞ0_StaPanΞ0_ConCon(__p1, __that, __nameScope) Line 108
14 Uno.UI.ResourceResolverSingleton.ApplyResource(owner, property, resourceKey, isThemeResourceExtension, isHotReloadSupported, context) Line 41
15 Uno.UI.ResourceResolver.ApplyResource(owner, property, resourceKey, isThemeResourceExtension, isHotReloadSupported, fromXamlParser, context) Line 293
16 Uno.UI.ResourceResolver.ApplyResource(owner, property, specializedKey, updateReason, context, precedence) Line 313
17 Uno.UI.ResourceResolver.TryStaticRetrieval(resourceKey, context, value) Line 488
18 Uno.Foundation.Logging.Logger.LogWarning(message)	Unknown

Expected behavior 🎯

the static resolution should just work, avoid having to resolve later via ResourceBinding

How to reproduce it (as minimally and precisely as possible) 🔬

Just launch the kahua403_StrictXamlCompile uno project on desktop: // kahua403_StrictXamlCompile.zip

@@ xaml
<Page>
	<Page.Resources>
		<x:String x:Key="VALID_RESOURCE">OK</x:String>
	</Page.Resources>
	<ContentControl x:Name="LazyControl" x:Load="False" Content="{StaticResource VALID_RESOURCE}" />
</Page>

@@cs
public MainPage()
{
	this.InitializeComponent();
	this.Loaded += (s, e) => this.FindName(nameof(LazyControl)); // force materalize x:Load=false
}

Workaround 🛠️

dont use lazy elements

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

All platforms 🌍

Uno.Sdk version (and other relevant versions) 📦

[email protected]

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

No response

Activity

  1. added
    triage/untriaged
    on Apr 20, 2026
  2. added theissue type on Apr 20, 2026
  3. self-assigned this
    on Apr 20, 2026
  4. added
    area/code-generation
    project/resources 🈷️
    on Apr 20, 2026
  5. removed
    triage/untriaged
    on Apr 20, 2026
  6. added a commit that references this issue on Apr 21, 2026
    5c5f8cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/code-generationproject/resources 🈷️

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions