Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGrid columns doesn't resize properly
    primarykey
    data
    text
    <p>I'm using a <code>DataGrid</code> in my WPF application to display some data. Upon application load, sometimes the Grid's columns get weird and the left "Select All" button disappears, causing the columns dividers not to be exactly where the column is. Only when the user tries to resize the column the Grids' layout becomes OK.</p> <p>My DataGrid definition is: <code>&lt;DataGrid Name="myList" AutoGenerateColumns="False" ItemsSource ="{Binding SortedView}" VirtualizingStackPanel.IsVirtualizing="False" ColumnWidth="Auto"&gt;</code></p> <p>Here is a screenshot of the problem for illustration:</p> <p><img src="https://i.stack.imgur.com/Hoe4S.png" alt="The bad layout of my DataGrid"></p> <p>Here's the full XAML code for the DataGrid:</p> <pre><code>&lt;DataGrid Name="myList" AutoGenerateColumns="False" ItemsSource ="{Binding SortedView}" VirtualizingStackPanel.IsVirtualizing="False" ColumnWidth="Auto"&gt; &lt;Interactivity:Interaction.Triggers&gt; &lt;Interactivity:EventTrigger EventName="Sorting" &gt; &lt;WPFCommon:InvokeDelegateCommandAction Command="{Binding SortCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" /&gt; &lt;/Interactivity:EventTrigger&gt; &lt;/Interactivity:Interaction.Triggers&gt; &lt;DataGrid.RowStyle&gt; &lt;Style TargetType="DataGridRow"&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch" /&gt; &lt;Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/&gt; &lt;/Style&gt; &lt;/DataGrid.RowStyle&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="{x:Static p:Resources.Sensor}" Binding="{Binding SensorName, Mode=OneWay}" Width="Auto" /&gt; &lt;DataGridTextColumn Header="{x:Static p:Resources.Status}" CanUserSort="True" Binding="{Binding Classification, Mode=OneWay}" Width="Auto" /&gt; &lt;DataGridTextColumn Header="{x:Static p:Resources.Created}" Binding="{Binding CreatedDate, Mode=OneWay}" CanUserSort="True" Width="Auto" IsReadOnly="True" /&gt; &lt;DataGridTextColumn Header="{x:Static p:Resources.Last_Updated}" Binding="{Binding LastUpdated, Mode=OneWay}" CanUserSort="True" Width="*" IsReadOnly="True" /&gt; &lt;/DataGrid.Columns &gt; &lt;/DataGrid&gt; </code></pre> <p>If anyone has an idea of how to get the <code>DataGrid</code> to automatically resize or refresh upon load / change it would be great.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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