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

Question: Can I declare a conditional XAML static resource? #2861

Closed
harvinders opened this issue Jul 8, 2020 · 9 comments
Closed

Question: Can I declare a conditional XAML static resource? #2861

harvinders opened this issue Jul 8, 2020 · 9 comments
Labels
area-Parser bug Something isn't working question team-Markup Issue for the Markup team

Comments

@harvinders
Copy link

I have a app with conditional ThemeShadow, it works fine with 1903+ however on 1803 it crashes. It complaints that there is a XAML parsing error.

<MainPage
    x:Class="App.Views.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:winui="using:Microsoft.UI.Xaml.Controls"
    xmlns:windows10Version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)"
    Style="{StaticResource PageStyle}"
    mc:Ignorable="d">
    <MainPage.Resources>
        <windows10Version1903:ThemeShadow x:Name="SharedShadow" />
    </MainPage.Resources>

Is there a workaround? Or am I doing something wrong?

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Jul 8, 2020
@Felix-Dev
Copy link
Contributor

@harvinders Does the XAML parsing error sound like the one in #2556? Or is a different error text?

@StephenLPeters
Copy link
Contributor

Can you show the xaml where you reference this resource as well? Also can you copy the full error you are seeing into this issue as well?

@StephenLPeters StephenLPeters added area-Parser needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Jul 8, 2020
@harvinders
Copy link
Author

harvinders commented Jul 9, 2020

@StephenLPeters Please find the repo at https://github.com/harvinders/ShadowTestApp

When run on the 1803 we get the error

Windows.UI.Xaml.Markup.XamlParseException
HResult=0x802B000A
Message=XAML parsing failed.

       at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
   at App1.MainPage.InitializeComponent() in C:\Users\mahimab\Downloads\ShadowTestApp-master\ShadowTestApp-master\App1\obj\x64\Debug\MainPage.g.i.cs:line 41
   at App1.MainPage..ctor() in C:\Users\mahimab\Downloads\ShadowTestApp-master\ShadowTestApp-master\App1\MainPage.xaml.cs:line 29

@msft-github-bot msft-github-bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Jul 9, 2020
@StephenLPeters StephenLPeters added needs-triage Issue needs to be triaged by the area owners team-Markup Issue for the Markup team and removed needs-triage Issue needs to be triaged by the area owners labels Jul 9, 2020
@StephenLPeters
Copy link
Contributor

@alwu-msft FYI

@evelynwu-msft
Copy link
Contributor

@harvinders You're not doing anything wrong; this looks like a bug in how single-item ResourceDictionaries interact with conditional XAML.

As a workaround, could you try adding a second item into that ResourceDictionary? It doesn't have to be used anywhere; what's important is that the ResourceDictionary contains at least two items in it.

@harvinders
Copy link
Author

@alwu-msft the work around worked.

@robloo
Copy link
Contributor

robloo commented Jul 10, 2020

There are several issues related to conditional XAML, #2556 is definitely in the same category of issues.

@StephenLPeters
It's become clear over the years that the XAML compiler is kind-of a mess. Is there any work or plans towards re-writing this? I heard rumors that Xamarin.Forms, UWP and WPF could all share the same XAML infrastructure. Even trying to rename .xaml to .winui is a result of some bad architecture here.

@evelynwu-msft
Copy link
Contributor

@robloo As one of the maintainers of the XamlCompiler toolchain (specifically, the parser), I suspect I share many of your frustrations. At the moment we are focused entirely on shipping WinUI 3.0 (which, unfortunately, is not likely to fundamentally change how we process XAML markup) but modernizing the architecture of XamlCompiler is very much something we want to tackle in the future; we have several ideas about how to go about doing this but they do have to be balanced with other competing priorities.

@robloo
Copy link
Contributor

robloo commented Jul 11, 2020

@alwu-msft Thanks for your response. I understand we all have to prioritize our time. It's encouraging to hear this has been discussed internally and is something that might be tackled in the future.

@fabiant3 fabiant3 added bug Something isn't working and removed needs-triage Issue needs to be triaged by the area owners labels Jul 31, 2020
@bpulliam bpulliam closed this as completed Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Parser bug Something isn't working question team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

8 participants