Textbox extends outside of the grid cell in .Net 4.0 (but not in 3.5)

Posted by Bryant on Stack Overflow See other posts from Stack Overflow or by Bryant
Published on 2010-05-21T22:24:08Z Indexed on 2010/05/22 11:00 UTC
Read the original article Hit count: 199

Filed under:

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?

© Stack Overflow or respective owner

Related posts about wpf