Home » WPF

How to align text with in Richtextbox in Wpf

hi All

I want to align the text within a richtextbox ie align top ,align bottom ,middle align

i can align the richtextbox object but not able to align text within the richtextbox

does anyone have solution for this problem




3 Answers Found


Answer 1


have you tried VerticalContentAlignment?


Answer 2

hi hbarck

i have tried this property but it is not working

i want to change  alignment on click of button align top,center,bottom

here rtb is the richtextbox's name


privatevoid button1_Click(object sender, RoutedEventArgs e)


rtb.VerticalContentAlignment = System.Windows.




any other idea



Answer 3

Hi Amit_hamirpur,

Flow document are designed to optimize viewing and readability. Rather than being set to one predefined layout, flow documents dynamically adjust and reflow their content based on tun-time variables such as window size, device resolution, and optional user preferences.

So, we cannot set the layout of the document in the RichTextBox manually, but for the paragraph, we can set the TextAlignment property. And you can also try to set the Padding property for the RichTextBox to adjust it content.

Hope this helps.

Best regards,
Kevin Pan



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure