Repository navigation
Open
Labels
difficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUIhas-repro-branchkind/bugSomething isn't workingproject/core-tools 🛠️Categorizes an issue or PR as relevant to core and tools
Description
How to reproduce it (as minimally and precisely as possible)
<Page.Resources>
<ResourceDictionary>
<SolidColorBrush x:Name="MyBrush" Color="Blue"/>
</ResourceDictionary>
</Page.Resources> public MainPage()
{
this.InitializeComponent();
MyBrush.ToString();
}Current behavior
1> C:\src\djo\tests\UnoTestbed15\UnoTestbed15\UnoTestbed15.Shared\MainPage.xaml.cs(33,4,33,11): error CS0103: The name 'MyBrush' does not exist in the current context
1> C:\src\djo\tests\UnoTestbed15\UnoTestbed15\UnoTestbed15.Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_3d81ab9d64dc9fbde82f418d1c389ae6.g.cs(313,5,313,12): error CS0103: The name 'MyBrush' does not exist in the current context
Expected behavior
Compiles as per UWP, resource entry can be referred to by name in code-behind
Workaround
Put the resource in a non-top-level element, eg:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.Resources>
<ResourceDictionary>
<SolidColorBrush x:Name="MyBrush"
Color="Blue" />
</ResourceDictionary>
</Grid.Resources>
<TextBlock Text="Hello, world!" Margin="20" FontSize="30" />
</Grid>Environment
Nuget Package:
- Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
- Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
- Uno.SourceGenerationTasks
- Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
- Other:
Nuget Package Version(s): 3.1.0-dev.288
Affected platform(s):
- iOS
- Android
- WebAssembly
- WebAssembly renderers for Xamarin.Forms
- macOS
- Skia
- WPF
- GTK (Linux)
- Tizen
- Windows
- Build tasks
- Solution Templates
IDE:
- Visual Studio 2017 (version: )
- Visual Studio 2019 (version: )
- Visual Studio for Mac (version: )
- Rider Windows (version: )
- Rider macOS (version: )
- Visual Studio Code (version: )
Relevant plugins:
- Resharper (version: )
Anything else we need to know?
Metadata
Metadata
Assignees
Labels
difficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUIhas-repro-branchkind/bugSomething isn't workingproject/core-tools 🛠️Categorizes an issue or PR as relevant to core and tools
Activity
MartinZikmund commentedon Jun 1, 2021
This is quite useful for
TeachingTipsupport, asx:Nameapproach is used often with itYoussef1313 commentedon Sep 16, 2021
Registering a name for the current scope is done under a condition:
Then,
RegisterBackingFieldcall (which I assume is responsible for generating the field) is gated under the same conditions.I don't have the complete background to know why the
isMemberInsideResourceDictionary.isInsidecheck is there in the first place. It doesn't look like a simple removal of the condition, I think there must be a reason it originally existed.Any ideas?
jeromelaban commentedon Sep 16, 2021
@Youssef1313 I don't recall the details for this, but looking at the associated commits will give you some context.
Youssef1313 commentedon Sep 16, 2021
@jeromelaban It exists from the very beginning:
There are compilation errors when I removed the condition in #7108, I'll look into that and adjust, and see if anything else breaks.
MartinZikmund commentedon Oct 8, 2021
I presume this scenario is the same?
Youssef1313 commentedon Oct 8, 2021
@MartinZikmund Yeah looks like it's the same. Is this a scenario blocking any control you're working on? Might worth re-testing with #7108 or after it's merged.
[-]Named Resource entries of top-level Xaml element aren't generated[/-][+]Named resource entries of top-level XAML element aren't generated[/+]lindexi commentedon Sep 21, 2023
Or
github-actions commentedon Jul 26, 2025
Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.
MartinZikmund commentedon Jul 27, 2025
Still relevant
test: Reproduce named resource in Page.Resources not generating named…
MartinZikmund commentedon Apr 7, 2026
Repro generator
Runtime test(s) added in branch
dev/mazi/repro/4032:src/Uno.UI.RuntimeTests/Tests/BindingTests/PageResourceNameTest.xaml+PageResourceNameTest.xaml.cssrc/Uno.UI.RuntimeTests/Tests/BindingTests/Given_PageResourceName_Issue4032.cs→When_Named_Resource_In_Page_Resources_ResourceDictionary_Is_AccessibleThe AT command has been deprecated. Please use schtasks.exe instead.
Invalid command.
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.
Root cause: The XAML source generator generates an assignment () in the generated
InitializeComponent()code but never generates the field declaration (). The error is in the generator's own output, not in user code. The bug is inXamlFileGenerator.cs— named resources inPage.Resources > ResourceDictionary(top-level element) don't get field declarations generated.