Table of Contents

Class ConfirmButton

Namespace
Tudormobile.Wpf.Controls
Assembly
Tudormobile.WpfControls.dll

Represents a button control that prompts the user for confirmation before performing the Click action and/or command.

The default confirmation dialog is a simple message box with "Yes" and "No" options. Use the ButtonText property to define up to three buttons with custom text, separated by the '|' character. The first button is considered the "affirmative" action, while the second and third buttons are considered "negative" actions. Buttons are placed from the right to the left in the order they are defined.

public class ConfirmButton : Button, IAnimatable, ISupportInitialize, IFrameworkInputElement, IInputElement, IQueryAmbient, IAddChild, ICommandSource
Inheritance
ConfirmButton
Implements
Inherited Members

Remarks

The ConfirmButton can be used in scenarios where user confirmation is required before executing a potentially destructive or critical operation. It inherits all functionality from the Button class and can be customized further as needed.

Fields

UserCancelledEvent

public static readonly RoutedEvent UserCancelledEvent

Field Value

RoutedEvent

Properties

ButtonText

Gets or sets the text displayed on the buttons. Up to three button texts can be defined, separated by the '|' character. By default, buttons are labeld "Yes" and "No" ("Yes|No") and displayed right to left. The first letter of each button text is used as the access key (mnemonic) for that button. The first button is considered the "affirmative" action.

public string? ButtonText { get; set; }

Property Value

string

Message

Gets or sets the confirmation message displayed to the user when the button is clicked. This message appears in the confirmation dialog and should clearly describe the action requiring user approval. If not set, the button's content or a default prompt is used.

public string Message { get; set; }

Property Value

string

WasCancelled

Gets or sets a value indicating whether the operation was cancelled. This property can be used to determine if the user chose to 'cancel' rather than just 'not confirm'. It is null if the button has not been clicked yet, true if the user cancelled, and false if the user confirmed.

public bool? WasCancelled { get; set; }

Property Value

bool?

Methods

OnClick()

Handles the click event for the control by displaying a confirmation dialog using the current theme mode.

protected override void OnClick()

Remarks

This method is called when the control is clicked. It first displays a confirmation dialog to the user, and, if the user confirms, it proceeds to execute the base class's OnClick method to perform the standard click action and or command.

RaiseUserCancelledRoutedEvent()

Raises the UserCancelledEvent routed event to notify listeners that the user has canceled an operation.

protected void RaiseUserCancelledRoutedEvent()

Events

UserCancelled

Occurs when the user cancels a confirmation dialog by pressing the 'cancel' button or hitting ESCAPE key.

public event RoutedEventHandler UserCancelled

Event Type

RoutedEventHandler

Remarks

This event is typically raised in response to user actions, such as clicking a "Cancel" button. Handlers for this event can be used to perform cleanup or rollback operations.