public ToolBoxGrid() { SizeChanged += delegate { var lastRowDefinition = RowDefinitions.Last(); var rowsHeight = RowDefinitions.Sum(rd => rd.ActualHeight); lastRowDefinition.Height = new GridLength(Math.Max(LastRowMinHeight, ActualHeight - rowsHeight + lastRowDefinition.ActualHeight)); }; }