none
How to Set Richtextbox Horizontal , vertical alignment into richtext box text code behind ?

    Question

  • How to Set  Richtextbox Horizontal , vertical alignment in code behind ? 

    if i am set MyRichTextBox.HorizontalAlignment=HorizontalAlignment.Right and MyRichTextBox.VerticalAlignment=VerticalAlignment.Bottom , 

    not applied to my richtextbox text ?


    Thanks & Regards, With Raghav



    Thursday, March 01, 2012 6:58 AM

Answers

All replies

  • Hi Raghav,

    What you mean by not applied to richtextbox text? I don't see such behavior. 

    Can you show the full code includes XAML and code behind to repro it?

    Thursday, March 01, 2012 10:03 AM
  • Hi Jenifer_Q , 

    Thank for your update , simply i will , how to set vertical-alignment for richtextbox text ? values like Top , Bottom , Center 


    Thanks & Regards, With Raghav

    Thursday, March 01, 2012 10:18 AM
  • Simply do this:

    XAML:

     <RichTextBox Name="richTB" Width="150" Height="200" >
                <FlowDocument>
                    <Paragraph>
                        <Run>Paragraph 1</Run>
                    </Paragraph>
                    <Paragraph>
                        <Run>Paragraph 2</Run>
                    </Paragraph>
                    <Paragraph>
                        <Run>Paragraph 3</Run>
                    </Paragraph>
                </FlowDocument>
            </RichTextBox>

    Code behind:

    richTB.VerticalContentAlignment = VerticalAlignment.Bottom;
    richTB.HorizontalContentAlignment = HorizontalAlignment.Right;

    Thursday, March 01, 2012 10:25 AM
  • Hi jenifer ,

    richTB.VerticalContentAlignment = VerticalAlignment.Bottom; richTB.HorizontalContentAlignment = HorizontalAlignment.Right;

    did u checked this one?? , not worked 


    Thanks & Regards, With Raghav

    Thursday, March 01, 2012 11:09 AM
  • Yup, it does work. What you mean by not work? The Text did not change position to the bottom right?
    Friday, March 02, 2012 3:09 AM
  • Text did not change position to the bottom right? yeah  That is my requirement  . whether it's worked in your application ?



    Thanks & Regards, With Raghav


    Friday, March 02, 2012 7:29 AM
  • How come?

    You can upload your application to SkyDrive and paste the link here. Then I can see what happened.

    Friday, March 02, 2012 8:32 AM
  • How come?  , ///

    i'm asking about that only , Why this didn't come , is there any way to align the text to vertically , Top , Middle , Bottom positions ?


    Thanks & Regards, With Raghav


    Friday, March 02, 2012 8:57 AM
  • Hi Raghav,

    MyRichTextBox.HorizontalAlignment=HorizontalAlignment.Right 

    MyRichTextBox.VerticalAlignment=VerticalAlignment.Bottom

    This code should work. I assume you did not set Width and Height of RichTextBox. Please give them values and see how.

    If that does not work for you, please share us your Xaml code for helping repro this issue.

    Have a nice day,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us


    Wednesday, March 07, 2012 8:59 AM
    Moderator
  • In addition to my last reply, The above code is to align RichTextBox, but if you mean to align the text inside RichTextBox, unfortunately,

    we cannot set the layout of flow document manually, as it dynamically adjust and reflow its content.

    Please read this thread for more information.

    http://social.msdn.microsoft.com/Forums/en/wpf/thread/8aaa5b74-fbc9-4b28-a423-7d1be60daca9

    Hope it helps,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 07, 2012 10:59 AM
    Moderator