Skip to content

Commit 773d2af

Browse files
Provide designer (propertygrid) support and control CodeDOM serialization for the CommandParameter property.
1 parent 47e9815 commit 773d2af

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/ButtonBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ public event EventHandler? CommandChanged
221221
/// which is assigned to the <see cref="Command"/> property.
222222
/// </summary>
223223
[Bindable(true)]
224-
[Browsable(false)]
225-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
226224
[SRCategory(nameof(SR.CatData))]
227225
[SRDescription(nameof(SR.CommandComponentCommandParameterDescr))]
226+
[TypeConverter(typeof(StringConverter))]
228227
public object? CommandParameter
229228
{
230229
get => _commandParameter;
@@ -238,6 +237,12 @@ public object? CommandParameter
238237
}
239238
}
240239

240+
private void ResetCommandParameter() => CommandParameter = null;
241+
242+
private bool ShouldSerializeCommandParameter() =>
243+
_commandParameter is string parameter
244+
&& !string.IsNullOrEmpty(parameter);
245+
241246
/// <summary>
242247
/// Occurs when the value of the <see cref="CommandParameter"/> property has changed.
243248
/// </summary>

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ public event EventHandler? CommandChanged
442442
/// which is assigned to the <see cref="Command"/> property.
443443
/// </summary>
444444
[Bindable(true)]
445-
[Browsable(false)]
446-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
447445
[SRCategory(nameof(SR.CatData))]
448446
[SRDescription(nameof(SR.CommandComponentCommandParameterDescr))]
447+
[TypeConverter(typeof(StringConverter))]
449448
public object? CommandParameter
450449
{
451450
get => _commandParameter;
@@ -460,6 +459,12 @@ public object? CommandParameter
460459
}
461460
}
462461

462+
private void ResetCommandParameter() => CommandParameter = null;
463+
464+
private bool ShouldSerializeCommandParameter() =>
465+
_commandParameter is string parameter
466+
&& !string.IsNullOrEmpty(parameter);
467+
463468
/// <summary>
464469
/// Occurs when the value of the <see cref="CommandParameter"/> property has changed.
465470
/// </summary>

0 commit comments

Comments
 (0)