views:

22

answers:

1

I have a TextBox that stretches to the width of the window:

<Window ...>
    <TextBox VerticalAlignment="Top" />
</Window>

However, the textbox should have a minimum width, and I want scroll bars to be shown, if the textbox cannot be displayed fully. Thus:

<Window ...>
    <ScrollViewer HorizontalScrollBarVisibility="Auto">
        <TextBox MinWidth="200" VerticalAlignment="Top" />
    </ScrollViewer>
</Window>

This, however, has a negative side effect. If the user enters more text than fits into the text box, the text box increases its size:

alt text

Is there a way to avoid this effect and still have the scroll bars if the minimum size of the textbox is reached?

+1  A: 

just have a look at this link

http://stackoverflow.com/questions/386039/wpf-textbox-and-scroll-behavior

Kishore Kumar
That's it, thanks. Voting to close my question now (duplicate).
Heinzi