In this post, I created a datagrid dynamically or from code. When a record is loaded, the scrolling is slow using Scrollviewer control. So to translate into code behind here's what i come up. Binding bindHeight = new Binding(); bindHeight.ElementName = String.Format( "sizingElement{0}" , index + 1); bindHeight.FallbackValue = 1; bindHeight.Path = new PropertyPath( "ActualHeight" ); //mapGrid is the datagrid object mapGrid.SetBinding(DataGrid.HeightProperty, bindHeight); XAML Markup: <StackPanel x:Name= "spThur" Height= "Auto" Background= "Green" HorizontalAlignment= "Left" Orientation= "Horizontal" > <Rectangle Name= "sizingElement4" Fill= "Transparent" Margin= "1" Height= "333" /> </StackPanel> The mapGrid datagrid is added to the stackpanel. And the Rectangle object is the sizing element.I found the solution from this ...