Xamarin.Forms - 在 ResourceDictionary 中使用 StaticResource

Xamarin.Forms - Using StaticResource inside ResourceDictionary

我有一个小应用程序,其中有一个带有 Syncfusion 的 SfChat 的 ContentPage,我试图对其进行一些自定义,所以我使用这样的 ResourceDictionary:

<ContentPage.Resources>
        <syncTheme:SyncfusionThemeDictionary>
            <syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <x:String x:Key="SfChatTheme">CustomTheme</x:String>
                    <x:String x:Key="SfChatIncomingMessageAuthorFontFamily">MontserratRegular</x:String>
                </ResourceDictionary>
            </syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
        </syncTheme:SyncfusionThemeDictionary>
    </ContentPage.Resources>

我的问题是“SfChatIncomingMessageAuthorFontFamily”属性 需要我的应用程序资源中的字体作为静态资源,所以我如何使用 {StaticResource MontserratRegular} 而不是仅仅将字体名称作为 x:string ?

比如用在标签上:

<ResourceDictionary>
    <OnPlatform
      x:Key="MediumFontFamily"
      x:TypeArguments="x:String"
      Android="sans-serif-medium"
      iOS="HelveticaNeue-Medium" />

</ResourceDictionary>

创建样式:

<Style x:Key="MyLabel" TargetType="Label">
   <Setter Property="FontFamily"
        Value="{StaticResource MediumFontFamily}" />
</Style>

然后在标签中使用:

<Label Style="{StaticResource MyLabel}" Text="Hello World" />