Embed baseline alignment information into a custom control

Hello,

I have designed some custom controls for displaying math equations and now I want to be able to display math equations in Paragraphs. First I was thinking to embed the control in a Figure, but the problem is that I need to align the control with the surrounding text. The alignment should be at baseline if my custom control has one, or if the control doesn't have a baseline (for example a fraction) the alignment should be at center.

How can I embed baseline alignment information into my custom control I have read about TextEmbeddedObject but I am not sure if this is the way to do it. Any suggestions are appreciated.

Regards,
Valentin Iliescu




Answer this question

Embed baseline alignment information into a custom control

  • SekharPC

    Ah, understood.

    You should be able to use the attached property BaselineOffset (I believe its defined on Inline or InlineUIContainer in the PDC builds). If you attach that property to your element, it will be used when performing baseline alignment.

    - filipe fortes
       


  • Prerna

    You're correct, in the PDC build it's defined on TextBlock. You should be able to attach that property to your element to do what you're looking for.     


  • markchimes

    Valentin,

    If you want to display the equation inline, you can use the BaselineAlignment property on InlineUIContainer. Here's a quick little sample on PDC bits:

        <TextBlock FontSize="20">Hello <InlineUIContainer BaselineAlignment="Top"><Rectangle Width="10" Fill="Blue" Height="10" /></InlineUIContainer> <InlineUIContainer BaselineAlignment="Bottom"><Rectangle Width="10" Fill="Blue" Height="10" /></InlineUIContainer>World!</TextBlock>




  • Tim Haines

    Thank you for your response, however I still have to figure how to embed "baseline" information into my control. Sometimes my custom control has a baseline (for example a text with underscript), I have already compute the baseline for this control, how do I let the text engine know that this is the baseline For example, if I put my custom control in an InlineUIContainer with BaselineAlignment="Baseline" the alignment should be between the surrounding text's baseline and my custom control's baseline.

    Sorry about this long explanation - I don't have experience with text engines.

    Thank you,
    Valentin



  • Dan Rogers

    I couldn't find BaselineOffset property in Inline or InlineUIContainer. I have searched in the documentation and only TextBlock has this property. Are you sure it's the PDC build you're talking about

    Thank you,
    Valentin



  • Embed baseline alignment information into a custom control