@@ -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,7 +157,7 @@ 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 {
@@ -200,7 +201,7 @@ public Control CreateSettingPanel()
200201 {
201202 Text = attributes . Label ,
202203 VerticalAlignment = VerticalAlignment . Center ,
203- TextWrapping = TextWrapping . WrapWithOverflow
204+ TextWrapping = TextWrapping . Wrap
204205 } ;
205206
206207 // Create a text block for description
@@ -211,7 +212,7 @@ public Control CreateSettingPanel()
211212 {
212213 Text = attributes . Description ,
213214 VerticalAlignment = VerticalAlignment . Center ,
214- TextWrapping = TextWrapping . WrapWithOverflow
215+ TextWrapping = TextWrapping . Wrap
215216 } ;
216217
217218 desc . SetResourceReference ( TextBlock . StyleProperty , "SettingPanelTextBlockDescriptionStyle" ) ; // for theme change
@@ -247,7 +248,8 @@ public Control CreateSettingPanel()
247248 VerticalAlignment = VerticalAlignment . Center ,
248249 Margin = SettingPanelItemLeftTopBottomMargin ,
249250 Text = Settings [ attributes . Name ] as string ?? string . Empty ,
250- ToolTip = attributes . Description
251+ ToolTip = attributes . Description ,
252+ TextWrapping = TextWrapping . Wrap
251253 } ;
252254
253255 textBox . TextChanged += ( _ , _ ) =>
@@ -269,7 +271,8 @@ public Control CreateSettingPanel()
269271 VerticalAlignment = VerticalAlignment . Center ,
270272 Margin = SettingPanelItemLeftMargin ,
271273 Text = Settings [ attributes . Name ] as string ?? string . Empty ,
272- ToolTip = attributes . Description
274+ ToolTip = attributes . Description ,
275+ TextWrapping = TextWrapping . Wrap
273276 } ;
274277
275278 textBox . TextChanged += ( _ , _ ) =>
@@ -333,7 +336,7 @@ public Control CreateSettingPanel()
333336 HorizontalAlignment = HorizontalAlignment . Stretch ,
334337 VerticalAlignment = VerticalAlignment . Center ,
335338 Margin = SettingPanelItemLeftTopBottomMargin ,
336- TextWrapping = TextWrapping . WrapWithOverflow ,
339+ TextWrapping = TextWrapping . Wrap ,
337340 AcceptsReturn = true ,
338341 Text = Settings [ attributes . Name ] as string ?? string . Empty ,
339342 ToolTip = attributes . Description
@@ -488,13 +491,37 @@ Settings[attributes.Name] is bool isChecked
488491 rowCount ++ ;
489492 }
490493
494+ mainPanel . SizeChanged += MainPanel_SizeChanged ;
495+
491496 // Wrap the main grid in a user control
492497 return new UserControl ( )
493498 {
494499 Content = mainPanel
495500 } ;
496501 }
497502
503+ private void MainPanel_SizeChanged ( object sender , SizeChangedEventArgs e )
504+ {
505+ if ( sender is not Grid grid ) return ;
506+
507+ var workingWidth = grid . ActualWidth ;
508+
509+ if ( workingWidth <= 0 ) return ;
510+
511+ var constrainedWidth = MainGridColumn0MaxWidthRatio * workingWidth ;
512+
513+ // Set MaxWidth of column 0 and its children
514+ // We must set MaxWidth of its children to make text wrapping work correctly
515+ grid . ColumnDefinitions [ 0 ] . MaxWidth = constrainedWidth ;
516+ foreach ( var child in grid . Children )
517+ {
518+ if ( child is FrameworkElement element && Grid . GetColumn ( element ) == 0 && Grid . GetColumnSpan ( element ) == 1 )
519+ {
520+ element . MaxWidth = constrainedWidth ;
521+ }
522+ }
523+ }
524+
498525 private static bool NeedSaveInSettings ( string type )
499526 {
500527 return type != "textBlock" && type != "separator" && type != "hyperlink" ;
0 commit comments