Question: Can I declare a conditional XAML static resource?
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Conditional Resources Creation WPF XAML Design / Run ...
Finally my question is : How can I conditionnaly let Resources be created in "low level" control ( so that I can have...
Read more >Conditional XAML - UWP applications
It selectively parses elements or attributes to determine whether they will be available at runtime. Conditional statements are evaluated at ...
Read more >Overview of XAML resources (WPF .NET)
Static resource references always load from XAML when the page loads. However, a dynamic resource reference doesn't load until it's used. You're ...
Read more >Intellisense help choosing SolidColorBrush name for a ...
Intellisense help choosing SolidColorBrush name for a Button in WPF XAML omits the "." seperator between StaticResource and custom key for SolidColorBClosed ...
Read more >DXimage in Static Resource without hard-coding ...
I would like to define a devexpress image in a resource so that it can be referenced in multiple places via StaticResource.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
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.