locked
Rotate a Content of WPF RichTextBox RRS feed

  • Question

  • I want to rotate the contents of RichTextBox in wpf like MS excel text orientation (Rotate Text 90 degree, Rotate Text 270 degree, Stacked text (Vertical)). I use FlowDocument as a Document of RichTextBox and i have tried using the RotateTransform method. But it doesnt help me excatly and also i didnt found any way to show stacked text (vertical) like excel inside RichTextBox. So please any one help me to achieve the above things.
    Friday, June 28, 2013 5:06 AM

Answers

  • Apply the LayoutTransform to the individual elements inside the FlowDocument:

          <RichTextBox>
            <FlowDocument>
                <Paragraph>
                  <TextBlock Text="Stacked text!">
                  <TextBlock.LayoutTransform>
                    <RotateTransform Angle="-90"></RotateTransform>
                  </TextBlock.LayoutTransform>
                  </TextBlock>
                </Paragraph>
              </FlowDocument>
          </RichTextBox>

    • Marked as answer by Lisa Zhu Monday, July 8, 2013 8:17 AM
    Friday, June 28, 2013 11:52 AM

All replies

  • Try this, Hope it would help you

    <TextBox  Text="Hello World" HorizontalAlignment="Right"  Name="textBox1" VerticalAlignment="Top"  VerticalContentAlignment="Top" >
                    <TextBox.LayoutTransform>
                        <RotateTransform Angle="-90"></RotateTransform>
                    </TextBox.LayoutTransform>
     </TextBox>

    Regards 

    Muhammad Arsalan Akhtar


    ars88

    Friday, June 28, 2013 6:31 AM
  • I am using RichTextBox not a TextBox and I want to rotate only the content of RichTextBox not the layout or rendering of richtextbox. So please guide me to rotate the content of RichTextBox.
    Friday, June 28, 2013 6:37 AM
  • Apply the LayoutTransform to the individual elements inside the FlowDocument:

          <RichTextBox>
            <FlowDocument>
                <Paragraph>
                  <TextBlock Text="Stacked text!">
                  <TextBlock.LayoutTransform>
                    <RotateTransform Angle="-90"></RotateTransform>
                  </TextBlock.LayoutTransform>
                  </TextBlock>
                </Paragraph>
              </FlowDocument>
          </RichTextBox>

    • Marked as answer by Lisa Zhu Monday, July 8, 2013 8:17 AM
    Friday, June 28, 2013 11:52 AM