Skip to content

Codegeneration is failed when using ResourceDictionary where elements requires code behind #12495

@FrozDark

Description

@FrozDark

Current behavior

Xaml parser fails with error System.Exception: Unable to find x:Class on the top level element

<ResourceDictionary
    x:Class="UnoAppIssues.Resources.ResourceDictionaryWithCodeBehind"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <MenuFlyout x:Key="someFlyout">
        <MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Some text" />
    </MenuFlyout>

</ResourceDictionary>

Code behind

public sealed partial class ResourceDictionaryWithCodeBehind : ResourceDictionary
    {
        public ResourceDictionaryWithCodeBehind()
        {
            this.InitializeComponent();
        }

        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {

        }
    }

Expected behavior

Xaml parse and code generation successfully

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

Repro:
XamlParseUnoAppIssues.zip

Workaround

None

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Uno 4.10.0-dev.111

Affected platforms

WebAssembly, Android, iOS, macOS (AppKit), Mac Catalyst, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Linux Framebuffer), Skia (Tizen)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/code-generationCategorizes an issue or PR as relevant to code generationdifficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUIkind/bugSomething isn't workingproject/core-tools 🛠️Categorizes an issue or PR as relevant to core and tools

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions