开发者

How to make TextBox scrollable in WPF

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 te开发者_JAVA百科xt box. I want to make that text box scrollable. Can you please give me the solution


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>


try:

<ScrollViewer>
    <Textbox/>
</ScrollViewer>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜