title: Binding grid Width to Datagrid Width wpf
body: <p>Is there a way to Bind the width of a grid Column Definition to Data Grid Column. Here is a part of my Xaml. Right now its hard coded if the Data Grid Column is expanded my Grid wont move along with it so I want to bind the Column Definition width to datagrid column width. Is there a way to do that..</p>
  
  <pre><code>&lt;StackPanel Grid.Row="2" Grid.ColumnSpan="2"&gt;
              &lt;Grid Margin="48" ShowGridLines="True"&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="104*"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="165*"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="166*"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="163*"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="58*"/&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Label Grid.Column="1" HorizontalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="53,0,50,0" Width="62"&gt;Extract&lt;/Label&gt;
                  &lt;Label Grid.Column="2" HorizontalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="49,0,29,0" Width="88"&gt;Transform&lt;/Label&gt;
                  &lt;Label Grid.Column="3" HorizontalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="59,0,58,0" Width="46"&gt;Load&lt;/Label&gt;
              &lt;/Grid&gt;
              &lt;DataGrid Name="dgEntities" Height="209" Margin="80,-52,55,-8"&gt;
                  &lt;DataGrid.Columns&gt;
                      &lt;DataGridTextColumn Header="Entity" Width="70"/&gt;
                      &lt;DataGridTextColumn Header="Status" Width="90"/&gt;
                      &lt;DataGridCheckBoxColumn Binding="{Binding IsSelected}" IsThreeState="True" Width="75"&gt;
                          &lt;DataGridCheckBoxColumn.HeaderTemplate&gt;
                              &lt;DataTemplate x:Name="dtAllChkBx"&gt;
                                  &lt;CheckBox Name="cbxAll"&gt;Checked&lt;/CheckBox&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridCheckBoxColumn.HeaderTemplate&gt;
                      &lt;/DataGridCheckBoxColumn&gt;
                      &lt;DataGridTextColumn Header="Status" Width="90"&gt;&lt;/DataGridTextColumn&gt;
                      &lt;DataGridCheckBoxColumn Binding="{Binding IsSelected}" IsThreeState="True" Width="75"&gt;
                          &lt;DataGridCheckBoxColumn.HeaderTemplate&gt;
                              &lt;DataTemplate x:Name="dtAllChkTransform"&gt;
                                  &lt;CheckBox Name="cbxAllTransform"&gt;Checked&lt;/CheckBox&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridCheckBoxColumn.HeaderTemplate&gt;
                      &lt;/DataGridCheckBoxColumn&gt;
  
                      &lt;DataGridTextColumn Header="Status" Width="90"&gt;&lt;/DataGridTextColumn&gt;
                      &lt;DataGridCheckBoxColumn Binding="{Binding IsSelected}" IsThreeState="True" Width="75"&gt;
                          &lt;DataGridCheckBoxColumn.HeaderTemplate&gt;
                              &lt;DataTemplate x:Name="dtAllChkLoad"&gt;
                                  &lt;CheckBox Name="cbxAllLoad"&gt;Checked&lt;/CheckBox&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/DataGridCheckBoxColumn.HeaderTemplate&gt;
                      &lt;/DataGridCheckBoxColumn&gt;
  
                  &lt;/DataGrid.Columns&gt;
              &lt;/DataGrid&gt;
  </code></pre>