@@ -61,6 +61,7 @@ public class ScrollablePanelControl : IWindowControl, IInteractiveControl, IFocu
6161 private StickyPosition _stickyPosition = StickyPosition . None ;
6262 private bool _visible = true ;
6363 private int ? _width ;
64+ private int ? _height ;
6465
6566 // IContainer properties
6667 private Color _backgroundColor = Color . Black ;
@@ -207,7 +208,7 @@ public bool AutoScroll
207208 #region IWindowControl Implementation
208209
209210 /// <inheritdoc/>
210- public int ? ContentHeight => null ; // Fill available space
211+ public int ? ContentHeight => _height ;
211212
212213 /// <inheritdoc/>
213214 public int ? ContentWidth => _width ;
@@ -289,6 +290,13 @@ public int? Width
289290 set { _width = value ; Container ? . Invalidate ( true ) ; }
290291 }
291292
293+ /// <inheritdoc/>
294+ public int ? Height
295+ {
296+ get => _height ;
297+ set => PropertySetterHelper . SetDimensionProperty ( ref _height , value , Container ) ;
298+ }
299+
292300 /// <inheritdoc/>
293301 public System . Drawing . Size GetLogicalContentSize ( )
294302 {
@@ -1137,12 +1145,23 @@ public LayoutSize MeasureDOM(LayoutConstraints constraints)
11371145 int width = _width ?? constraints . MaxWidth ;
11381146 int availableWidth = Math . Max ( 1 , width - _margin . Left - _margin . Right ) ;
11391147
1140- // Pass the actual available width to CalculateContentHeight
1141- int height = CalculateContentHeight ( availableWidth ) ;
1148+ // Determine height
1149+ int height ;
1150+ if ( _height . HasValue )
1151+ {
1152+ // Explicit height set - use it directly
1153+ height = _height . Value ;
1154+ }
1155+ else
1156+ {
1157+ // No explicit height - calculate from content
1158+ int contentHeight = CalculateContentHeight ( availableWidth ) ;
1159+ height = contentHeight + _margin . Top + _margin . Bottom ;
1160+ }
11421161
11431162 return new LayoutSize (
11441163 Math . Clamp ( width + _margin . Left + _margin . Right , constraints . MinWidth , constraints . MaxWidth ) ,
1145- Math . Clamp ( height + _margin . Top + _margin . Bottom , constraints . MinHeight , constraints . MaxHeight )
1164+ Math . Clamp ( height , constraints . MinHeight , constraints . MaxHeight )
11461165 ) ;
11471166 }
11481167
0 commit comments