Conditional XAML not working in ResourceDictionaries
See original GitHub issueDescribe the bug Been having trouble trying to add more complex conditional XAML to our Resource Dictionaries (like just copying resources from the WinUI repo here that is using the same syntax is failing in our C# UWP Class Library).
The latest message I’ve received is Type 'TemplateBinding' used after '{' must be a Markup Extension. Error code 0x09cc.
which seems similar to this old thread here.
Steps to reproduce the bug
- Clone WCT repo
- Open a ResourceDictionary for a control like (TokenizingTextbox.AutoSuggestBox.xaml)
- Paste in a system style for
AutoSuggestBox
(grabbed from Generic.xaml from 18362 for instance) - Use VS Quick-Fix tip to apply conditional XAML for Description property.
- Try and compile. This should be valid XAML, but it fails.
I noticed this as well when trying to apply CornerRadius conditionally as well.
Expected behavior Compile and run.
Screenshots
Version Info Class Library Min: 16299, Target 17763
Windows 10 version | Saw the problem? |
---|---|
May 2020 Update (19041) | Yes |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Mobile | |
Xbox | |
Surface Hub | |
IoT |
VS 2019 16.5.5
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How to conditionally include XAML ResourceDictionary in ...
1 Answer 1 ... The error is caused by the path of Colors.xaml . ... Update: It's also valid to place all resources...
Read more >Conditional XAML does not work with Setters
It seems there is a problem with XAML compiler that prevents conditional XAML from working with Style Setters in Resource dictionaries.
Read more >ResourceDictionary Class (Windows.UI.Xaml) - UWP
Defines a repository for XAML resources, such as styles, that your app uses. You define the resources in XAML and can then retrieve...
Read more >Untitled
WebAug 12, 2020 · To use a Xaml ResourceDictionary without a partial class (code behind class) (as indicated by the x:Class attribute), remove...
Read more >Managing Application Resources when WPF is Hosted
Dear Dr. WPF,. We are running into some issues around application level resources when we attempt to put WPF task pane UI within...
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
Hitting this again with the Expander setter:
https://github.com/microsoft/microsoft-ui-xaml/blob/f132a034af64f83c65a2a20590c39399558905a4/dev/Expander/Expander.xaml#L6-L24
Looks like it is coming from both our UWP and WinAppSDK passes. The error message is also less helpful now than it was before.
I just copied the style into a new C# class library (in our Toolkit Labs) as I’m trying to investigate inheriting from the WinUI Expander for the Toolkit for 8.0. (Though since our min target is 17763, I think I can remove these checks, but still very confused why this is working in some places but not others still.)
This problem persists even when targeting 19041 (min 17134).
It only affects
Setter
s in my case. I usecontract7Present:CornerRadius
andcontract7Present:Description
in other places in this file and it compiles just fine.VS 2019 16.8.3