tags:

views:

347

answers:

1

The standard WPF TextBox control does not scroll the overflowing text into caret position as one types text into the control. Is it possible to create this behavior in a singeline WPF TextBox control? If so - How? An example of this behavior is the default way a HTML input type=text acts in most (if not all?) browsers.

+1  A: 

The TextBox will have that behavior unless it is allowed to stretch infinitely.

<StackPanel>
 <StackPanel Orientation="Horizontal"
    Margin="5">
  <TextBlock Text="No Horizontal Scrolling:" />
  <TextBox HorizontalAlignment="Stretch"
     MinWidth="100" />
 </StackPanel>
 <StackPanel Orientation="Horizontal"
    Margin="5">
  <TextBlock Text="Horizontal Scrolling:" />
  <TextBox Width="100" />
 </StackPanel>
 <StackPanel Orientation="Horizontal"
    Margin="5">
  <TextBlock Text="Horizontal Scrolling:" />
  <TextBox HorizontalAlignment="Stretch"
     MinWidth="50"
     MaxWidth="100" />
 </StackPanel>
 <DockPanel Margin="5">
  <TextBlock DockPanel.Dock="Left"
       Text="Horizontal Scrolling:" />
  <TextBox />
 </DockPanel>
</StackPanel>
rmoore