Textbox extends outside of the grid cell in .Net 4.0 (but not in 3.5)
- by Bryant
There seems to be a change in behaviour between .Net 3.5 and .Net 4.0.
If I define a window as:
<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="500" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="1" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" Text="abc abc abc abc abc abc abc abc abcabc abc abcabc abc abc abc abc abc" />
</Grid>
</Window>
In .Net 3.5 the textbox correctly contains itself within the grid cell but in .Net 4.0 it extends beyond the cell and so gets clipped. This only happens if the MinWidth of the first column is greater than 50% of the overall width.
Does anyone know how to get 4.0 to exhibit the same behavior as 3.5?