xaml-math icon indicating copy to clipboard operation
xaml-math copied to clipboard

Not possible to set default style of FormulaControl in app?

Open samirem opened this issue 7 years ago • 4 comments
trafficstars

I'm trying to set a default style for FormulaControl in my entire app. At the moment it doesn't work, and I believe it might be related to this SO answer: https://stackoverflow.com/a/39364416/4351604

If i'm correct, this should be added to FormulaControl.cs

static MyControl()
{
    DefaultStyleKeyProperty.OverrideMetadata(
        typeof(FormulaControl),
        new FrameworkPropertyMetadata(typeof(FormulaControl))); 
}

samirem avatar Dec 18 '17 22:12 samirem

@samirem, could you please elaborate on what are you trying to do?

I've tried to add the code you asked, and now the control doesn't renders at all. From other answers, it looks like we miss the control template, and currently I have no idea what to put into it (because I've never authored my own control before).

Could you please share the proposed usage of the control, i.e. what do you want to customize?

ForNeVeR avatar Jan 20 '18 08:01 ForNeVeR

Very late reply, but recently I've stumbled upon the same issue. What I'm trying to do is apply default styles to my FormulaControl's using a keyless Style-tag like the following:

<Style TargetType="{x:Type wpfMath:FormulaControl}">
    ...
</Style>

However, that does not seem to work, and I suspect that the issue has to do with DefaultStyleKey not being overridden. I will try to see if I can figure out how it should be solved.

samirem avatar Mar 10 '23 20:03 samirem

Could you please elaborate a bit more? What particular aspect of styling are you trying to change?

(and it's nice to see you after these years, hope you are okay 😅)

ForNeVeR avatar Mar 10 '23 23:03 ForNeVeR

Sure! I have lots of FormulaControls in the same app and I want them all to use the same values for SystemTextFontName, TextOptions.TextRenderingMode, TextOptions.TextHintingMode, etc.

samirem avatar Mar 10 '23 23:03 samirem