Problem

Ribbon Control Font Style

Posted 9 months ago by Avatar Andree Dailey

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 8 months ago by Actipro Software Support - Cleveland, OH, USA

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
Information The latest build of this product (2018.1 build 0670) was released 10 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.