2

I using one header control in wpf application in that I am using Grid and in that grid I am putting List box some buttons and text box. I want to make that text box scrollable. Can you please give me the solution

2 Answers 2

8

For a TextBox, set its following properties:

<TextBox AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

You said:

I have tried this but it is not working

<Label Content="Log Details" Grid.Row="4" ></Label>
<Border Margin="7,7,7,3" Grid.Row="5">
  <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="5" > 
    <StackPanel >
      <TextBox Margin="5" AcceptsReturn="True"
               VerticalScrollBarVisibility="Visible" IsReadOnly="True" 
               x:Name="LogDetails" /> 
    </StackPanel>
  </ScrollViewer>
</Border>

I am putting this in headercontrol. – jolly

Actually, you don't need to put a TextBox into a ScrollViewer since TextBox already has a ScrollViewer associated in its Template.

But if you are having your specific requirement in which you need to do the same, you can try something like this:

<Label Content="Log Details" Grid.Row="4" ></Label>
<Border Margin="7,7,7,3" Grid.Row="5">
  <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="5" >
    <StackPanel>
      <TextBox Margin="5" TextWrapping="Wrap"
               AcceptsReturn="True" IsReadOnly="True"
               x:Name="LogDetails" />
    </StackPanel>
  </ScrollViewer>
</Border>
Sign up to request clarification or add additional context in comments.

Comments

3

try:

<ScrollViewer>
    <Textbox/>
</ScrollViewer>

1 Comment

I have tried this but it is not working <Label Content="Log Details" Grid.Row="4" ></Label> <Border Margin="7,7,7,3" Grid.Row="5"> <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="5" > <StackPanel > <TextBox Margin="5" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" IsReadOnly="True" x:Name="LogDetails"></TextBox> </StackPanel> </ScrollViewer> </Border> I am putting this in headercontrol.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.