FontFamily in xaml

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
kmatt
Posts: 30
Joined: Wed Feb 01, 2017 11:16 am

FontFamily in xaml

Postby kmatt » Mon Apr 03, 2017 4:56 am

I can't get the <FontFamily> to work in xaml even though it was supposedly released in beta 7. There is no parameterless constructor for it, which automatically means it can't work in xaml. How then do you use it as a StaticResource?

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: FontFamily in xaml

Postby JS-Support @Userware » Mon Apr 03, 2017 5:23 am

Hi,

I got the following XAML code to work, can you please tell me if this is the same approach that you are using? (please ignore possible design-time XAML editor errors)

Code: Select all

<Border>
    <Border.Resources>
        <FontFamily x:Key="TestFont">Wingdings</FontFamily>
    </Border.Resources>
    <TextBlock Text="This is a test" FontFamily="{StaticResource TestFont}"/>
</Border>


Thanks.
Regards,
JS-Support

kmatt
Posts: 30
Joined: Wed Feb 01, 2017 11:16 am

Re: FontFamily in xaml

Postby kmatt » Thu Apr 06, 2017 5:09 am

I thought I would get a notification when a reply was posted, but I did not.

No, not exactly. I've tried several ways:

<Page.Resources>
<ResourceDictionary>
<FontFamily x:Key="EatonLightFont">Arial</FontFamily>
</ResourceDictionary>
</Page.Resources>

<Page.Resources>
<FontFamily x:Key="EatonLightFont">Arial</FontFamily>
</Page.Resources>

Which would then be called out like so:
FontFamily="{StaticResource EatonLightFont}"
inside an element like a Listbox or other control, in the Page, ChildWindow and UserControl elements, and:

<ChildWindow.FontFamily>
<StaticResource ResourceKey="EatonLightFont"/>
</ChildWindow.FontFamily>

In the same places (ChildWindow, UserControl and Page).

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: FontFamily in xaml

Postby JS-Support @Userware » Thu Apr 06, 2017 8:50 am

Hi,

Thanks a lot for your reply.

For a quick resolution, can you please reproduce the issue in a new empty project and attach it to this thread? This way we can reproduce it as well and fix it very quickly.

Thanks again.
Regards,
JS-Support

kmatt
Posts: 30
Joined: Wed Feb 01, 2017 11:16 am

Re: FontFamily in xaml

Postby kmatt » Fri Apr 07, 2017 11:09 am

I'm sorry, but I can't completely reproduce it in a small project with only a button. It was there in the new small project until I got rid of the last "other" compiler error (I had no method yet for the button click), but when I added the OnClick method the FontFamily compiler error went away too. I can't eliminate all of my project down to a single button, so that doesn't help much. By the way, the error shows up in the xaml file (as squiggly lines under the FontFamily) and in the compiler. In my real project I don't get any other compiler errors or squiggly lines in the xaml, just the FontFamily one.

kmatt
Posts: 30
Joined: Wed Feb 01, 2017 11:16 am

Re: FontFamily in xaml

Postby kmatt » Fri Apr 07, 2017 12:04 pm

Apparently ANY StaticResource Xaml properties are my issue. Once I removed all the FontFamily ones, my ButtonStyle ones started showing up as errors.

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: FontFamily in xaml

Postby JS-Support @Userware » Fri Apr 07, 2017 3:31 pm

Thanks for the reply. Does the FontFamily error appear also if you close the XAML editor and recompile the project?


Return to “Bug Reports”

Who is online

Users browsing this forum: Google [Bot] and 21 guests