I want the text box to grow in size until it fills its container. If you put an empty text field in a WPF window, it will increase in size (as the user enters text into it) until it fills the container, after which it will no longer expand in size.
However, if I put this text field in a grid, the text field does not stop growing. And even a stranger, if I rigidly set a fixed width on the grid columns, even the STILL text box will continue to grow.
I want the text field to increase and the grid to increase, but as soon as the grid can no longer grow, I want the text field to stop growing too. It can be done?
Here is a quick example. When you enter text in a text box, it will increase in size (optional). However, the text box will continue to grow even after the grid fills out the WPF form completely.
<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" Name="window"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Text="StackOverflow"/> <TextBox Grid.Column="1"/> </Grid> </Window>
source share