File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,26 @@ public ToolbarControl()
5151 }
5252
5353 /// <inheritdoc/>
54- public override int ? ContentWidth => Width ;
54+ public override int ? ContentWidth => Width ?? ComputeContentWidth ( ) ;
55+
56+ private int ? ComputeContentWidth ( )
57+ {
58+ if ( _items . Count == 0 ) return null ;
59+ int total = 0 ;
60+ foreach ( var item in _items )
61+ {
62+ if ( item is ButtonControl btn )
63+ total += btn . ContentWidth ?? 0 ;
64+ else if ( item is SeparatorControl )
65+ total += 1 ;
66+ else
67+ total += item . ContentWidth ?? item . Width ?? 0 ;
68+ }
69+ total += Math . Max ( 0 , _items . Count - 1 ) * ItemSpacing ;
70+ total += _contentPadding . Left + _contentPadding . Right ;
71+ total += Margin . Left + Margin . Right ;
72+ return total ;
73+ }
5574
5675 /// <summary>
5776 /// Gets or sets the background color of the toolbar.
You can’t perform that action at this time.
0 commit comments