Ribbon Control Font Style

Ribbon for WPF Forum

Posted 7 years ago by Andree Dailey
Version: 16.1.0635
Platform: .NET 4.6
Environment: Windows 7 (64-bit)
Avatar

Hi,

I have created a style that targets the ribbon control.  In the style I set the font size and font family.  Here is an example of my style:

<Style x:Key="ribbonStyle2" TargetType="{x:Type ribbon:Ribbon}">
<Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
</Style>

I set the style on my ribbon, like this:

<ribbon:Ribbon x:Name="ribbon" Style="{StaticResource ribbonStyle2}"

When I run the application the font style and size doesn't get applied.  If I set the properties directly on the ribbon control it works fine.

Here is an example:

<ribbon:Ribbon x:Name="Ribbon" Grid.Row="0" FontSize="14" FontFamily="{DynamicResource DefaultFontFamily}" TextOptions.TextFormattingMode="Display">

I really need to be able to use a style because I have many applications that are using the ribbon control and I want one style to rule them all :).  Please let me know how I can fix this.

Thanks,

Alyssa

Comments (1)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Alyssa,

Yes, the problem here is that we have to have some programmatic logic in place to set the defaults for the FontFamily and FontSize, because the values we set can change based on a couple factors.  Since we are setting it in code, it prevents the Style from being able to be applied.

What you could possibly do is make a class with an attached property that you set, and in the property changed handler for that, programmatically set the FontFamily and FontSize properties of the target object (the Ribbon).  That would likely work around the problem, and that attached property could probably be set in your Style.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.