Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to remove the MinWidth you set for all the data grid columns, you could also set the data grid columns Width="*" to fill-in all the space available the them. see the code below </p> <p>Ok, I found it, please remove the HorizontalAlignment from both m_MainGrid and m_DataGrid, moreover, remove all the ColumnDefinitions in m_MainGrid. I tried it on your solution and it worked.</p> <p><img src="https://i.stack.imgur.com/9kyZI.png" alt="Please follow the following steps"></p> <pre><code>&lt;Window x:Class="Data_Grid_Issue.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"&gt; &lt;Grid&gt; &lt;Grid Margin="50" &gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="50"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Border x:Name="m_Border" CornerRadius="5,5,0,0" BorderBrush="Black" Margin="20,0,0,0" BorderThickness="1,1,1,0" HorizontalAlignment="Left" Background="LightBlue" Width="{Binding ElementName=m_DataGrid, Path=ActualWidth}"&gt; &lt;Label Content="Hello" HorizontalAlignment="Center"/&gt; &lt;/Border&gt; &lt;Grid x:Name="m_MainGrid" Grid.Row="1"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;!--&lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}" /&gt; &lt;ColumnDefinition Width="{Binding ElementName=col2, Path=ActualWidth}" /&gt; &lt;ColumnDefinition Width="{Binding ElementName=col3, Path=ActualWidth}" /&gt; &lt;ColumnDefinition Width="{Binding ElementName=col4, Path=ActualWidth}" /&gt; &lt;/Grid.ColumnDefinitions&gt;--&gt; &lt;DataGrid ScrollViewer.ScrollChanged="m_DataGrid_ScrollChanged" Width="Auto" x:Name="m_DataGrid" ItemsSource="{Binding Path= Testing}" AutoGenerateColumns="False" Margin="0,0,0,0" EnableRowVirtualization="True" RowHeaderWidth="20" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Width="Auto" Binding="{Binding Path=a}" MinWidth="200" x:Name="col1" Header="Col1"&gt;&lt;/DataGridTextColumn&gt; &lt;DataGridTextColumn Width="Auto" Binding="{Binding Path=b}" MinWidth="200" x:Name="col2" Header="Col2"&gt;&lt;/DataGridTextColumn&gt; &lt;DataGridTextColumn Width="Auto" Binding="{Binding Path=c}" MinWidth="200" x:Name="col3" Header="Col3"&gt;&lt;/DataGridTextColumn&gt; &lt;DataGridTextColumn Width="Auto" Binding="{Binding Path=d}" MinWidth="200" x:Name="col4" Header="Col4"&gt;&lt;/DataGridTextColumn&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/Grid&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload