I'm trying to build a data grid where one of the columns is a font name displayed in that font. Previously, I was working with a list box where I had defined the following template:

<TextBlock Text="{Binding Path=Name}" FontFamily="{Binding Path=Name}"/>

This worked just fine. So, I tweaked the data structure (Name became Font.Name) and moved onto a data grid to try this:

<dg:DataGridTextColumn Binding="{Binding Font.Name}" 
    FontFamily="{Binding Font.Name}" IsReadOnly="True" Header="Font"/>

Now the font names are all displayed in the default font, and I get this error:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or 
FrameworkContentElement for target element. 
BindingExpression:Path=Font.Name; DataItem=null; target element is 
'DataGridTextColumn' (HashCode=56915998); target property is 'FontFamily' 
(type 'FontFamily')

A few Google results dealing with custom controls suggest changing the property from DependencyObject to FrameworkElement, but I'd have to inherit DataGridTextColumn and define my own property to do so - there must be a better way.

I've tried several different approaches to the binding, including attempting to change just the font size with a distinct property in my data class (i.e., FontSize="{Binding FontSize}"). They've all resulted in the same error as above.

Anyone know what I'm doing wrong here?

Edit:

Thanks to Jared's reply, I found the following:

https://learn.microsoft.com/en-us/archive/blogs/jaimer/forwarding-the-datagrids-datacontext-to-its-columns

The method looks sound, but I need to make a binding that references the correct element in the DataContext for each row, as opp

Edit
Report