'Is it possible to reference the FontFamily key declared in one resource dictionary, in a FontFamily declaration in another resource dictionary

I have a resource dictionary file that contains Roboto fontfamily declarations, I'll call it Roboto.xaml . It declares a FontFamily key value of "RobotoLight". It has entries that appears as:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   <FontFamily x:Key="RobotoLight">/<assembly name>;Component/Roboto/Roboto-Light.ttf#Roboto</FontFamily>

:

</ResourceDictionary>

The Roboto.xaml resource dictionary is loaded into the Application.Current.Resources.MergedDictionaries.

I have another resource dictionary, I'll call it UXFonts.xaml that has fontfamily references the "RobotoLight" key in the Roboto.xaml . It has entries that appear as:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <FontFamily x:Key="UXButton_FontFamily">RobotoLight</FontFamily>
:

</ResourceDictionary>

It is then loaded into the Application.Current.Resources.MergedDictionaries.

The issue is, the entries in the UXFonts.xaml resource dictionary are not producing any desired results. If I reference the FontFamily key "UXButton_FontFamily", it has no effect. I'm assuming that this is because the UXFonts.xaml declarations are specifying the Roboto.xaml FontFamily key value, instead of directly specifying the Roboto-Light.ttf font file path.

My question is, is there a way to format the UXFonts.xaml file entries to reference the Roboto.xaml FontFamily key, instead of having to specify the Roboto-Light.ttf font file path?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source