Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XamlTypeInfo forgets to generate type information if only used as type #6232

Closed
1 of 2 tasks
huoyaoyuan opened this issue Nov 4, 2021 · 3 comments
Closed
1 of 2 tasks
Labels
area-XamlCompiler product-winui3 WinUI 3 issues team-Markup Issue for the Markup team

Comments

@huoyaoyuan
Copy link

huoyaoyuan commented Nov 4, 2021

Describe the bug

XamlTypeInfo forgets to generate type information if the type is only used as type xaml, not object or property.

Steps to reproduce the bug

  1. Create a project with WinUI3, and install CommunityToolkit.WinUI.UI 7.1.1-preview3
  2. Create an enum named MyEnum
  3. Add following xaml:
    xmlns:wctk="using:CommunityToolkit.WinUI.UI"
<ListView ItemsSource="{wctk:EnumValues Type=local:MyEnum}" />
  1. The markup extension receives a null type, and fails to provide values of the enum.

Expected behavior

Enum values shown in the ListView.

Screenshots

N/A

NuGet package version

WinUI 3 - Windows App SDK 1.0.0-preview3

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

May 2021 Update (19043)

Additional context

The workaround is to create a dummy object:

        <StackPanel.Resources>
            <local:MyEnum x:Key="__Dummy">0</local:MyEnum>
        </StackPanel.Resources>

Having a control with the enum as a property will make it generates correctly.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Nov 4, 2021
@StephenLPeters StephenLPeters added area-XamlCompiler product-winui3 WinUI 3 issues team-Markup Issue for the Markup team labels Nov 5, 2021
@StephenLPeters
Copy link
Contributor

@RealTommyKlein and @evelynwu-msft FYI

@RealTommyKlein
Copy link
Contributor

Thanks for the report - this will be fixed in Windows App SDK 1.1. As an alternative workaround, you can also add the Microsoft.UI.Xaml.Data.Bindable attribute to the types being assigned to the property, e.g.:

[Microsoft.UI.Xaml.Data.Bindable]
enum MyEnum
{
    ....
}

@RealTommyKlein
Copy link
Contributor

This is fixed for the upcoming Windows App SDK 1.1 release - also, closing this issue as a dupe of #4161

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-XamlCompiler product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

3 participants