maxc137
maxc137

Reputation: 2771

Suppress error in xaml using .editorconfig

I have following XAML. It's valid (and code compiles and runs just fine), but VS gives me the error: "XLS0505 Type 'FontImageSource' is used like a markup extension but does not derive from MarkupExtension"

<Image Source="{FontImageSource Color={DynamicResource PrimaryColor}}"/>

How can I suppress it in .editorconfig? Tried this dotnet_diagnostic.XLS0505.severity = none, but it didn't work.

Upvotes: 0

Views: 293

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

In XAML there is a special syntax that allows the code to perform additional rules and indirectly set other objects. See the official Microsoft Docs on Markup Extensions.

So in your case you could set the FontImageSource like following

<Image >
    <Image.Source>
        <FontImageSource
        FontFamily="{DynamicResource MaterialFontFamily}"
        Glyph="{Binding xxx}"
        Size="44"
        Color="{DynamicResource PrimaryColor}"/>
    </Image.Source>
    
</Image>

Upvotes: 0

Related Questions