@@ -27,6 +27,7 @@ public class JsonRPCPluginSettings : ISavable
27
27
28
28
private JsonStorage < ConcurrentDictionary < string , object ? > > _storage = null ! ;
29
29
30
+ private static readonly double MainGridColumn0MaxWidthRatio = 0.6 ;
30
31
private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
31
32
private static readonly Thickness SettingPanelItemLeftMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemLeftMargin" ) ;
32
33
private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
@@ -156,7 +157,7 @@ public Control CreateSettingPanel()
156
157
{
157
158
if ( ! NeedCreateSettingPanel ( ) ) return null ! ;
158
159
159
- // Create main grid with two columns (Column 1 : Auto, Column 2 : *)
160
+ // Create main grid with two columns (Column 0 : Auto, Column 1 : *)
160
161
var mainPanel = new Grid { Margin = SettingPanelMargin , VerticalAlignment = VerticalAlignment . Center } ;
161
162
mainPanel . ColumnDefinitions . Add ( new ColumnDefinition ( )
162
163
{
@@ -200,7 +201,7 @@ public Control CreateSettingPanel()
200
201
{
201
202
Text = attributes . Label ,
202
203
VerticalAlignment = VerticalAlignment . Center ,
203
- TextWrapping = TextWrapping . WrapWithOverflow
204
+ TextWrapping = TextWrapping . Wrap
204
205
} ;
205
206
206
207
// Create a text block for description
@@ -211,7 +212,7 @@ public Control CreateSettingPanel()
211
212
{
212
213
Text = attributes . Description ,
213
214
VerticalAlignment = VerticalAlignment . Center ,
214
- TextWrapping = TextWrapping . WrapWithOverflow
215
+ TextWrapping = TextWrapping . Wrap
215
216
} ;
216
217
217
218
desc . SetResourceReference ( TextBlock . StyleProperty , "SettingPanelTextBlockDescriptionStyle" ) ; // for theme change
@@ -247,7 +248,8 @@ public Control CreateSettingPanel()
247
248
VerticalAlignment = VerticalAlignment . Center ,
248
249
Margin = SettingPanelItemLeftTopBottomMargin ,
249
250
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
250
- ToolTip = attributes . Description
251
+ ToolTip = attributes . Description ,
252
+ TextWrapping = TextWrapping . Wrap
251
253
} ;
252
254
253
255
textBox . TextChanged += ( _ , _ ) =>
@@ -269,7 +271,8 @@ public Control CreateSettingPanel()
269
271
VerticalAlignment = VerticalAlignment . Center ,
270
272
Margin = SettingPanelItemLeftMargin ,
271
273
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
272
- ToolTip = attributes . Description
274
+ ToolTip = attributes . Description ,
275
+ TextWrapping = TextWrapping . Wrap
273
276
} ;
274
277
275
278
textBox . TextChanged += ( _ , _ ) =>
@@ -333,7 +336,7 @@ public Control CreateSettingPanel()
333
336
HorizontalAlignment = HorizontalAlignment . Stretch ,
334
337
VerticalAlignment = VerticalAlignment . Center ,
335
338
Margin = SettingPanelItemLeftTopBottomMargin ,
336
- TextWrapping = TextWrapping . WrapWithOverflow ,
339
+ TextWrapping = TextWrapping . Wrap ,
337
340
AcceptsReturn = true ,
338
341
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
339
342
ToolTip = attributes . Description
@@ -488,13 +491,37 @@ Settings[attributes.Name] is bool isChecked
488
491
rowCount ++ ;
489
492
}
490
493
494
+ mainPanel . SizeChanged += MainPanel_SizeChanged ;
495
+
491
496
// Wrap the main grid in a user control
492
497
return new UserControl ( )
493
498
{
494
499
Content = mainPanel
495
500
} ;
496
501
}
497
502
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
+
498
525
private static bool NeedSaveInSettings ( string type )
499
526
{
500
527
return type != "textBlock" && type != "separator" && type != "hyperlink" ;
0 commit comments