ResourceDictionary 中的 OnPlatform 引发错误 "The property 'Default' is set more than once"

OnPlatform inside a ResourceDictionary raises error "The property 'Default' is set more than once"

我的 ResourceDictionary 中的以下代码片段导致 XLS0501 - 属性 'Default' 在编辑文件时设置了不止一次。

<!-- Fonte Padrao -->
<OnPlatform x:Key="DefaultFont" x:TypeArguments="x:String">
    <On Platform="Android" Value="Droid Sans"/>
    <On Platform="iOS" Value="MarkerFelt-Thin"/>
</OnPlatform>

但是,如果我关闭文件并且 运行 我的解决方案工作正常,甚至在我的应用程序上设置了正确的字体。

"Default is set more than once"

这是一个已知问题,您可以忽略 "Default is set more than once" 或 "Platforms is not an attachable property",因为它们是假错误(这是这个开放问题的重点,语言服务不应该被标记作为错误)。您可以在错误输出 window 中选择 Build 而不是 Build + IntelliSense 以显示合法错误

GitHub : https://github.com/xamarin/Xamarin.Forms/issues/3839