To reproduce the issue:
Spam a letter (for example) until you start hitting the right gridsplitter area. The gridsplitter gets moved past the right side min-width limit.
Expected behaviour: Going over the width limit when typing (type/paste) into the textbox does not move the gridsplitter, but immediately activates the scrollbar.
Conditions
- The TextBox must be horizontally and vertically scrollable
- The TextBox and the ScrollViewer must remain dynamically sizable – no maxwidth limit. That’s because in the real application, the user can resize the app, which results in the textbox being resized.
Code:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10000*" MinWidth="25"/>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" MinWidth="25" />
</Grid.ColumnDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<TextBox AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" />
</ScrollViewer>
<GridSplitter Background="Black"
BorderBrush="White"
BorderThickness="1,0,0,0"
ResizeDirection="Columns"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Grid.Column="1" />
<Grid Background="Red" Grid.Column="2" />
</Grid>
Thats causing problems
Use percentage values for you column definition instead: