Please tell me how I can set the height at the initial loading of the DataGrid table using DoubleAnimation so that it does not go beyond the last row. I tried to use both MaxHeght and ActualHeight anyway, the width is trying to reach the final value.

enter image description here

And I would like, like this:

enter image description here

<Grid> <DataGrid x:Name="DGR" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="Auto" Width="Auto" MaxHeight="200" MaxWidth="200" AutoGenerateColumns="False" Loaded="DGR_Loaded" > <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Name}" Header="Name"/> <DataGridTextColumn Binding="{Binding SecondName}" Header="SecondName"/> <DataGridTextColumn Binding="{Binding Phone}" Header="Phone"/> </DataGrid.Columns> </DataGrid> public class Person { public string Name { get; set; } public string SecondName { get; set; } public int Phone { get; set; } } public partial class MainWindow : Window { public ObservableCollection<Person> person = null; public MainWindow() { InitializeComponent(); if (person == null) { person = new ObservableCollection<Person>(); DGR.ItemsSource = person; } } private void DGR_Loaded(object sender, RoutedEventArgs e) { DoubleAnimation widthAnim = new DoubleAnimation(); widthAnim.From = 0; widthAnim.To = this.ActualHeight; widthAnim.Duration = TimeSpan.FromSeconds(5.5); DGR.BeginAnimation(HeightProperty, widthAnim); } } 
  • Comments are not intended for extended discussion; conversation moved to chat . - JuriySPb

0