@@ -28,6 +28,7 @@ public class JsonRPCPluginSettings : ISavable
28
28
29
29
private JsonStorage < ConcurrentDictionary < string , object ? > > _storage = null ! ;
30
30
31
+ private static readonly double MainGridColumn0MaxWidthRatio = 0.6 ;
31
32
private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
32
33
private static readonly Thickness SettingPanelItemLeftMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemLeftMargin" ) ;
33
34
private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
@@ -157,7 +158,7 @@ public Control CreateSettingPanel()
157
158
{
158
159
if ( ! NeedCreateSettingPanel ( ) ) return null ! ;
159
160
160
- // Create main grid with two columns (Column 1 : Auto, Column 2 : *)
161
+ // Create main grid with two columns (Column 0 : Auto, Column 1 : *)
161
162
var mainPanel = new Grid { Margin = SettingPanelMargin , VerticalAlignment = VerticalAlignment . Center } ;
162
163
mainPanel . ColumnDefinitions . Add ( new ColumnDefinition ( )
163
164
{
@@ -201,7 +202,7 @@ public Control CreateSettingPanel()
201
202
{
202
203
Text = attributes . Label ,
203
204
VerticalAlignment = VerticalAlignment . Center ,
204
- TextWrapping = TextWrapping . WrapWithOverflow
205
+ TextWrapping = TextWrapping . Wrap
205
206
} ;
206
207
207
208
// Create a text block for description
@@ -212,7 +213,7 @@ public Control CreateSettingPanel()
212
213
{
213
214
Text = attributes . Description ,
214
215
VerticalAlignment = VerticalAlignment . Center ,
215
- TextWrapping = TextWrapping . WrapWithOverflow
216
+ TextWrapping = TextWrapping . Wrap
216
217
} ;
217
218
218
219
desc . SetResourceReference ( TextBlock . StyleProperty , "SettingPanelTextBlockDescriptionStyle" ) ; // for theme change
@@ -248,7 +249,8 @@ public Control CreateSettingPanel()
248
249
VerticalAlignment = VerticalAlignment . Center ,
249
250
Margin = SettingPanelItemLeftTopBottomMargin ,
250
251
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
251
- ToolTip = attributes . Description
252
+ ToolTip = attributes . Description ,
253
+ TextWrapping = TextWrapping . Wrap
252
254
} ;
253
255
254
256
textBox . TextChanged += ( _ , _ ) =>
@@ -270,7 +272,8 @@ public Control CreateSettingPanel()
270
272
VerticalAlignment = VerticalAlignment . Center ,
271
273
Margin = SettingPanelItemLeftMargin ,
272
274
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
273
- ToolTip = attributes . Description
275
+ ToolTip = attributes . Description ,
276
+ TextWrapping = TextWrapping . Wrap
274
277
} ;
275
278
276
279
textBox . TextChanged += ( _ , _ ) =>
@@ -336,7 +339,7 @@ public Control CreateSettingPanel()
336
339
HorizontalAlignment = HorizontalAlignment . Stretch ,
337
340
VerticalAlignment = VerticalAlignment . Center ,
338
341
Margin = SettingPanelItemLeftTopBottomMargin ,
339
- TextWrapping = TextWrapping . WrapWithOverflow ,
342
+ TextWrapping = TextWrapping . Wrap ,
340
343
AcceptsReturn = true ,
341
344
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
342
345
ToolTip = attributes . Description
@@ -491,13 +494,37 @@ Settings[attributes.Name] is bool isChecked
491
494
rowCount ++ ;
492
495
}
493
496
497
+ mainPanel . SizeChanged += MainPanel_SizeChanged ;
498
+
494
499
// Wrap the main grid in a user control
495
500
return new UserControl ( )
496
501
{
497
502
Content = mainPanel
498
503
} ;
499
504
}
500
505
506
+ private void MainPanel_SizeChanged ( object sender , SizeChangedEventArgs e )
507
+ {
508
+ if ( sender is not Grid grid ) return ;
509
+
510
+ var workingWidth = grid . ActualWidth ;
511
+
512
+ if ( workingWidth <= 0 ) return ;
513
+
514
+ var constrainedWidth = MainGridColumn0MaxWidthRatio * workingWidth ;
515
+
516
+ // Set MaxWidth of column 0 and its children
517
+ // We must set MaxWidth of its children to make text wrapping work correctly
518
+ grid . ColumnDefinitions [ 0 ] . MaxWidth = constrainedWidth ;
519
+ foreach ( var child in grid . Children )
520
+ {
521
+ if ( child is FrameworkElement element && Grid . GetColumn ( element ) == 0 && Grid . GetColumnSpan ( element ) == 1 )
522
+ {
523
+ element . MaxWidth = constrainedWidth ;
524
+ }
525
+ }
526
+ }
527
+
501
528
private static bool NeedSaveInSettings ( string type )
502
529
{
503
530
return type != "textBlock" && type != "separator" && type != "hyperlink" ;
0 commit comments