0

in a WPF window I have a TextBox inside a ScrollViewer:

<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" MaxHeight="160" Grid.Column="1" Grid.Row="0">
    <TextBox MinHeight="80" Name="generalLog"/>
</ScrollViewer>

With an empty text it looks like this.

When the text gets to long or contains too many lines, the scrollbars appear, as they should. But as the TextBox is wrapped inside the ScrollViewer, the TextBox gets bigger and its border (default style) gets hidden on the sides:

Link to Screenshot because I can't embed pictures

As you can see, the border is not visible on the left side. Is there any way to make the ScrollViewer appear inside the TextBox? Or make the ScrollViewer have a border like the TextBox and hide the TextBox one, which would probably look the way I want.

Thanks so much.

1 Answer 1

1

Wrap the Scrollviewer with a border and set Textbox borderbrush="transparent" ?

<Border>
  <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" MaxHeight="160" Grid.Column="1" Grid.Row="0">
   <TextBox BorderBrush="transparent" MinHeight="80" Name="generalLog"/>
  </ScrollViewer>
</Border>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.