How can I make the WPF TextBox scroll text into caret position?
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 typ开发者_如何学运维e=text acts in most (if not all?) browsers.
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>
精彩评论