I have some custom fonts defined in ResourceDictionary
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Fonlow.VA.App">
<Application.Resources>
<ResourceDictionary>
<OnPlatform x:TypeArguments="x:String" x:Key="SuperFont">
<On Platform="Android" Value="Super.ttf#Super" />
<On Platform="UWP" Value="/Assets/Super.ttf#Super" />
<!--<On Platform="iOS" Value="OpenSans-Bold" />-->
</OnPlatform>
<OnPlatform x:TypeArguments="x:String" x:Key="NormalFont">
<On Platform="Android" Value="Normal.ttf#Normal" />
<On Platform="UWP" Value="/Assets/Normal.ttf#Normal" />
<!--<On Platform="iOS" Value="OpenSans-Bold" />-->
</OnPlatform>
</ResourceDictionary>
</Application.Resources>
And
<Label Text="{Binding CurrentOptotype.Text}" FontFamily="{StaticResource SuperFont}" FontSize="{Binding CurrentFontSize}" TextColor="Black" />
So far so good. However, I would switch the FontFamily at runtime through ViewModel binding just like the binding for FontSize, since CurrentFontSize is a property in the View Model. I had tried:
FontFamily="{Binding CurrentFontFamily}"
And the value of CurrentFontFamily can point to an existing system font, but I want to point to a custom font pointing to what defined in ResourceDictionary.
I had then tried:
FontFamily="{StaticResource {Binding CurrentFontFamily}}"
And there's runtime error obviously against such makeup syntax. I just wonder whether there's a in XAML to switch custom font at runtime through MVVM View Model?