@@ -27,6 +27,7 @@ public class JsonRPCPluginSettings : ISavable
2727
2828 private JsonStorage < ConcurrentDictionary < string , object ? > > _storage = null ! ;
2929
30+ private static readonly double MainGridColumn0MaxWidthRatio = 0.6 ;
3031 private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
3132 private static readonly Thickness SettingPanelItemLeftMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemLeftMargin" ) ;
3233 private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
@@ -156,11 +157,12 @@ public Control CreateSettingPanel()
156157 {
157158 if ( ! NeedCreateSettingPanel ( ) ) return null ! ;
158159
159- // Create main grid with two columns (Column 1 : Auto, Column 2 : *)
160+ // Create main grid with two columns (Column 0 : Auto, Column 1 : *)
160161 var mainPanel = new Grid { Margin = SettingPanelMargin , VerticalAlignment = VerticalAlignment . Center } ;
161162 mainPanel . ColumnDefinitions . Add ( new ColumnDefinition ( )
162163 {
163- Width = new GridLength ( 0 , GridUnitType . Auto )
164+ Width = new GridLength ( 0 , GridUnitType . Auto ) ,
165+ MaxWidth = MainGridColumn0MaxWidthRatio * 560 // 560 is the default available width
164166 } ) ;
165167 mainPanel . ColumnDefinitions . Add ( new ColumnDefinition ( )
166168 {
@@ -488,13 +490,27 @@ Settings[attributes.Name] is bool isChecked
488490 rowCount ++ ;
489491 }
490492
493+ mainPanel . SizeChanged += MainPanel_SizeChanged ;
494+
491495 // Wrap the main grid in a user control
492496 return new UserControl ( )
493497 {
494498 Content = mainPanel
495499 } ;
496500 }
497501
502+ private void MainPanel_SizeChanged ( object sender , SizeChangedEventArgs e )
503+ {
504+ if ( sender is not Grid grid ) return ;
505+
506+ var workingWidth =
507+ ( int ) ( grid . ActualWidth - SystemParameters . VerticalScrollBarWidth ) ; // take into account vertical scrollbar
508+
509+ if ( workingWidth <= 0 ) return ;
510+
511+ grid . ColumnDefinitions [ 0 ] . MaxWidth = MainGridColumn0MaxWidthRatio * workingWidth ;
512+ }
513+
498514 private static bool NeedSaveInSettings ( string type )
499515 {
500516 return type != "textBlock" && type != "separator" && type != "hyperlink" ;
0 commit comments