Binding a FontFamily ViewModel Property

I want to bind FontFamily to a TextBox to the property that I created on my ViewModel

Here is my xaml:

<TextBox Text="Test Font Binding" FontFamily="{Binding FontFirstContent}" />

And here is the property in my ViewModel:

public FontFamily FontFirstContent
{
    get { return new FontFamily("Verdana"); }
}

When the view is loaded, the property receiver starts correctly, but it is not passed in the view. All the bindings in my view work except this one, so I don’t understand what is wrong with him?

Edit: Good, great! I was just working on the wrong FontFamily object. I used:

System.Drawing.FontFamily

But FontFamily must be of type:

System.Windows.Media.FontFamily
+4
source share
1 answer

Here is something that I added in ResourceDictionaryintended for the default style for my application:

<FontFamily x:Key="MyFontFamily">Segoe UI</FontFamily>

, FontFamily :

<Label Content="Something" FontFamily="{DynamicResource MyFontFamily}"/>

ResourceDictionary .

, ;

+1

All Articles