title: How to make textboxes width dynamically like buttons in xaml
body: <p>I have textboxes with some textblocks above it. </p>
  
  <p>I want my application to have resizable width (not height) so I have setted only <em>MinWidth</em> for window. So when I click on right or left border of window I can scale it however I want. </p>
  
  <p>My problem is, that when I use textboxes I don't get result what I would like to have. </p>
  
  <p>If I position textboxes with textblock above it on <em>MinWidth</em> of window, after making the window bigger those textboxes will stay with same width on the same place according to ColumnDefinitions.</p>
  
  <p>It does make sence since those textboxes have fixed width setted on 160 but if I try same thing with buttons according same columndefinitions and stuff those buttons gonna stretch according window size and it will be sorted by columndefintions. </p>
  
  <p>Is there way how to acomplish same thing with textboxes? So when I stretch window from 1050px to full size 1920px mine textboxes would change width so it can be dynamically? <em>Width="Auto"</em> doesn't solve it for me</p>
  
  <p>Adding images below so you can imagine it better hopefully.</p>
  
  <p>xaml: </p>
  
  <pre><code>&lt;UserControl x:Class="App.NewUI.Textboxes"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           xmlns:local="clr-namespace:App.NewUI"
           mc:Ignorable="d" 
           d:DesignHeight="720" MaxHeight="720" d:DesignWidth="1050"&gt;
  &lt;Border Padding="10"&gt;
      &lt;StackPanel&gt;
  
          &lt;!-- TextBoxes + update button --&gt;
          &lt;Grid Margin="0 5 0 0"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;TextBox x:Name="txtBoxFirstname" Text="{Binding SelectedItem.Firstname, ElementName=dg}" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/&gt;
              &lt;TextBox x:Name="txtBoxLastname" Text="{Binding SelectedItem.Lastname, ElementName=dg}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/&gt;
              &lt;TextBox x:Name="txtBoxTelephone" Text="{Binding SelectedItem.Telephone, ElementName=dg}" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/&gt;
              &lt;TextBox x:Name="txtBoxBorn" Text="{Binding SelectedItem.Born, ElementName=dg}" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/&gt;
              &lt;TextBox x:Name="txtBoxCategory" Text="{Binding SelectedItem.Category, ElementName=dg}" Grid.Column="4" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/&gt;
  
              &lt;Button x:Name="btnUpdateRecord" Content="Update Record" Grid.Column="5" Click="btnUpdateRecord_Click"/&gt;
  
          &lt;/Grid&gt;
  
          &lt;!-- datagrid --&gt;
          &lt;Grid Margin="0 15 0 0"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="3*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;DataGrid x:Name="dg" Grid.Column="0" Margin="0,0,0,-350" Width="auto" Height="350"/&gt;
          &lt;/Grid&gt;
  
      &lt;/StackPanel&gt;
  &lt;/Border&gt;
  </code></pre>
  
  <p></p>
  
  <p>I've tried to set textboxes width to auto but then textboxes will be tiny without text and won't stretch anyway. Thank you for any tip</p>
  
  <p><a href="https://imgur.com/a/lPEexu0" rel="nofollow noreferrer">Imgur images of window</a></p>