ScrollViewer with Size down strange behavior...

May 25, 2010 at 4:19 PM

Hi all, I Got the sample xaml...

The problem is when resizing the window (enlarge) the textbox with resize, if I shrink the window, the texbox stays large

I dit test with 3.5 and 4.0 same thing...

I surround my textbox with a border so it won't resize the window... and if the user resize the window, the user will have more space..

Any Clues ? 

 

<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="TestScrollViewer.MainWindow"
	x:Name="Window"
         Height="200"
         Width="400"
	Title="MainWindow">
    <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Label Content="Dummy label" Grid.Column="0" />

            <Border x:Name="bd" Grid.Column="1" >
                <!--The problem is when resise the window it work, but when size down doesn't go back in original state...-->
                <TextBox Width="{Binding ElementName=bd, Path=ActualWidth}" Text="{Binding Path=ActualWidth, ElementName=bd, Mode=OneWay}" />
            </Border>
        </Grid>
    </ScrollViewer>
</Window>