Changing TextEffects of a FlowDocument are not displayed

I am trying to modify a RichTextBox to "rotate" its text flow vertically instead of horizontally.

I've been trying to do this by modifying the TextEffects property in the RichTextBox's FlowDocument. However, changing the TextEffects seems to have no effect.

My code is as follows:

System.Windows.Media.TextEffect effect = new System.Windows.Media.TextEffect();

effect.Transform = new System.Windows.Media.RotateTransform(90);

effect.PositionCount = 100;

System.Windows.Media.TextEffectCollection effects = new System.Windows.Media.TextEffectCollection();

effects.Add(effect);

textBox.Document.TextEffects = effects;

Note that I've successfully been able to apply TextEffects to a TextBlock using the same approach. However, it doesn't work with a FlowDocument.

My suspicion is that this may be a bug in FlowDocument, because the following sample has the same problem: http://windowssdk.msdn.microsoft.com/library/default.asp url=/library/en-us/wcp_samples/html/1893f725-dbe0-401e-b0f5-d5957604a1fd.asp.

(I'm using Jan CTP of WinFX)

Any help would be appreciated, thanks!



Answer this question

Changing TextEffects of a FlowDocument are not displayed

  • Funk

    I was playing around with this a bit more, applying TextEffects to specfic Runs works for me. This may help you work around adding it to the root FlowDoc while we sort out what's going wrong there. (I added a TranslateTransform because the text would get clipped by the TextBox otherwise).

    //Setting up some text in the RichTextBox

    textBox.Document = new FlowDocument(new Paragraph(new Run("Hello World this is text")));

    //Adding TextEffects

    System.Windows.Media.TextEffect effect = new System.Windows.Media.TextEffect();

    effect.Transform = new System.Windows.Media.RotateTransform(90);

    effect.PositionCount = 100;

    System.Windows.Media.TextEffect effect2 = new System.Windows.Media.TextEffect();

    effect2.Transform = new System.Windows.Media.TranslateTransform(0, -10);

    effect2.PositionCount = 100;

    System.Windows.Media.TextEffectCollection effects = new System.Windows.Media.TextEffectCollection();

    effects.Add(effect);

    effects.Add(effect2);

    //Applying to the first Run:

    Paragraph p = textBox.Document.Blocks.FirstBlock as Paragraph;

    p.Inlines.FirstInline.TextEffects = effects;


  • smcirish

    D.Mac,

    This does look like a bug, thanks for discovering this issue!! I'll make sure the team tracks this.

    Thanks again,

    Chris


  • Changing TextEffects of a FlowDocument are not displayed