UserPromptButtonBuilder Class
Defines a builder for configuring and creating Button instances to be shown on a user prompt.
public sealed class UserPromptButtonBuilder
- Inheritance:
- object object
Properties
Command
The value to be assigned to Command.
CommandParameter
The value to be assigned to CommandParameter.
ContentClipboardText
The value to be assigned to ButtonClipboardTextProperty.
public string? ContentClipboardText { get; }
Property Value
See Also
Instance
The Button instance that is being configured.
public Button? Instance { get; }
Property Value
Remarks
This property is not populated until Build(UserPromptBuilder) is initiated.
See Also
IsCancel
The value to be assigned to IsCancel and, when true,
indicates the Result of the button should be used as the CloseResult.
IsDefault
The value to be assigned to IsDefault and, when true,
indicates the configured Result of the button should be used as the DefaultResult.
Result
The value to be assigned to ButtonResultProperty.
public UserPromptStandardResult Result { get; }
Property Value
Remarks
This property can also be used to automatically coerce the Label.
See Also
Methods
AfterBuild(Action<UserPromptButtonBuilder>?)
Registers a delegate to be called after the build is complete.
public UserPromptButtonBuilder AfterBuild(Action<UserPromptButtonBuilder>? callback)
| Parameter | Type | Description |
|---|---|---|
| callback | Action<UserPromptButtonBuilder> | The callback, which will be invoked after any already registered callbacks are invoked. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
AfterInitialize(Action<UserPromptButtonBuilder>?)
Registers a delegate to be called after the Instance is created, but before the build starts.
public UserPromptButtonBuilder AfterInitialize(Action<UserPromptButtonBuilder>? callback)
| Parameter | Type | Description |
|---|---|---|
| callback | Action<UserPromptButtonBuilder> | The callback, which will be invoked after any already registered callbacks are invoked. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
Build(UserPromptBuilder)
Creates and configures a Button based on the current builder configuration.
public Button Build(UserPromptBuilder parent)
| Parameter | Type | Description |
|---|---|---|
| parent | UserPromptBuilder | The parent UserPromptBuilder. |
Returns
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
Configure()
Initializes a new instance of UserPromptButtonBuilder for creating Button instances.
public static UserPromptButtonBuilder Configure()
Returns
- UserPromptButtonBuilder:
A new instance of UserPromptButtonBuilder.
Configure<TButton>()
Initializes a new instance of UserPromptButtonBuilder for creating Button instances of type TButton.
public static UserPromptButtonBuilder Configure<TButton>() where TButton : Button, new()
- Type Parameters:
-
TButton-The Button type.
Returns
- UserPromptButtonBuilder:
A new instance of UserPromptButtonBuilder.
Configure<TButton>(Func<TButton>)
Initializes a new instance of UserPromptButtonBuilder for creating Button instances of type TButton.
public static UserPromptButtonBuilder Configure<TButton>(Func<TButton> buttonFactory) where TButton : Button
- Type Parameters:
-
TButton-The Button type.
| Parameter | Type | Description |
|---|---|---|
| buttonFactory | Func<TButton> | The factory method that will create a new instance of |
Returns
- UserPromptButtonBuilder:
A new instance of UserPromptButtonBuilder.
UseAsCloseResult()
Sets the IsCancel property value and, when true,
indicates the configured Result of the button should be used as the CloseResult.
public UserPromptButtonBuilder UseAsCloseResult()
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
UseAsDefaultResult()
Sets the IsDefault property value and, when true,
indicates the configured Result of the button should be used as the DefaultResult.
public UserPromptButtonBuilder UseAsDefaultResult()
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
WithCommand(ICommand?, object?)
Sets the command confirmation for the button.
public UserPromptButtonBuilder WithCommand(ICommand? command, object? commandParameter = null)
| Parameter | Type | Description |
|---|---|---|
| command | ICommand | The value to be assigned to Command. |
| commandParameter | object | The value to be assigned to CommandParameter. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
WithContent(Func<object?>?)
Sets the content of the button.
public UserPromptButtonBuilder WithContent(Func<object?>? contentFactory)
| Parameter | Type | Description |
|---|---|---|
| contentFactory | Func<object> | The factory method for creating content. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
WithContent(Func<Button, object?>?)
Sets the content of the button.
public UserPromptButtonBuilder WithContent(Func<Button, object?>? contentFactory)
| Parameter | Type | Description |
|---|---|---|
| contentFactory | Func<Button, object> | The factory method for creating content, which also passes a reference the current Instance. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
WithContent(object?)
Sets the content of the button.
public UserPromptButtonBuilder WithContent(object? content)
| Parameter | Type | Description |
|---|---|---|
| content | object | The content. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
WithContentClipboardText(string?)
Sets the ContentClipboardText property value.
public UserPromptButtonBuilder WithContentClipboardText(string? text)
| Parameter | Type | Description |
|---|---|---|
| text | string | The text. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.
See Also
WithResult(UserPromptStandardResult)
Sets the Result property value.
public UserPromptButtonBuilder WithResult(UserPromptStandardResult result)
| Parameter | Type | Description |
|---|---|---|
| result | UserPromptStandardResult | The result to assign. |
Returns
- UserPromptButtonBuilder:
This builder instance, which can be used for method chaining.