tags:

views:

3890

answers:

2

Hi,

I have a TextBlock in WPF. I write many lines to it, far exceeding its vertical height. I expected a vertical scroll bar to appear automatically when that happens, but it didn't. I tried to look for a scroll bar property in the Properties pane, but could not find one.

How can I a vertical scroll bar created automatically for my TextBox once its contents exceed its height?

Clarification: I would rather do it from the designer and not by directly writing to the XAML.

Thanks

+9  A: 

Wrap is in a scroll viewer:

<ScrollViewer>
    <TextBlock />
</ScrollViewer>
Drew Noakes
How do I do it from the designer?
Bab Yogoo
Sorry I am not sure, I don't use the WPF designer. I think if you add the XAML directly, the designer will update itself.
Drew Noakes
It works, thanks
Bab Yogoo
You're welcome!
Drew Noakes
+6  A: 

can use the following now:

    <TextBox Name="myTextBox" 
             ScrollViewer.HorizontalScrollBarVisibility="Auto"
             ScrollViewer.VerticalScrollBarVisibility="Auto"
             ScrollViewer.CanContentScroll="True">SOME TEXT</TextBox>
vince