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

UserControl does not compile with WinAppSDK #16708

Closed
ArchieCoder opened this issue May 13, 2024 · 3 comments
Closed

UserControl does not compile with WinAppSDK #16708

ArchieCoder opened this issue May 13, 2024 · 3 comments
Assignees
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. question Further information is requested triage/untriaged Indicates an issue requires triaging or verification

Comments

@ArchieCoder
Copy link
Contributor

Current behavior

When the WinAppSDK target is selected, my 2 UserControls don't compile:

Severity Code Description Project File Line Suppression State Details
Error WMC0001 Unknown type 'TitleWithAppControl' in XML namespace 'clr-namespace:ElementsTechnician.Presentation;assembly=Test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Test C:\Users\sebas\Downloads\ElementsTechnician\ElementsTechnician\Presentation\MainPage.xaml 111

It compiles fine with the other targets.

Expected behavior

It should compile with all targets.

My user control is simply a StackPanel with a TextBlock

<StackPanel
    Background="Blue"
    Orientation="Horizontal"
    Padding="8">

    <TextBlock
        FontSize="30"
        Foreground="White"
        HorizontalAlignment="Center"
        Text="Blue"
        VerticalAlignment="Center" />

</StackPanel>

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

Open this sample app and compile Test.zip

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

Windows (WinAppSDK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@ArchieCoder ArchieCoder added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels May 13, 2024
@Youssef1313 Youssef1313 added question Further information is requested and removed kind/bug Something isn't working labels May 13, 2024
@Youssef1313
Copy link
Member

Youssef1313 commented May 13, 2024

In MainPage.xaml, you have xmlns:presentation="clr-namespace:ElementsTechnician.Presentation"

This should be replaced by xmlns:presentation="using:ElementsTechnician.Presentation"

The fact that it compiles in Uno targets is a behavior that we will likely change a breaking change to keep parity with WinUI.

This is the same scenario from #15813

@ArchieCoder
Copy link
Contributor Author

ArchieCoder commented May 13, 2024

Good catch, I confirm it compiles. I'm puzzled how I ended up with this xmlns line. I never write this explicitly, I always use what VS/Resharper suggests. I guess one of them was wrong.

@Youssef1313
Copy link
Member

Probably ReSharper isn't able to recognize the XAML as "WinUI" XAML if it doesn't respect DefaultXamlRuntime.

Or maybe this could have happened if you were typing code while restore hasn't completed, in which case, the DefaultXamlRuntime property isn't yet set and probably VS and/or Rider falls back to WPF flavored XAML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. question Further information is requested triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants