In This Article

UserPromptControl Class

Represents a prompt displayed to a user with an option to respond.

[TemplatePart(Name = "PART_ButtonItemsControl", Type = typeof(UserPromptButtonItemsControl))]
public class UserPromptControl : HeaderedContentControl
Inheritance:
object Visual UIElement FrameworkElement Control ContentControl HeaderedContentControl object

Constructors

UserPromptControl()

Initializes a new instance of the UserPromptControl class.

public UserPromptControl()

Properties

ButtonItems

Gets or sets the items which define the buttons to be presented on the prompt.

public IEnumerable? ButtonItems { get; set; }

Property Value

IEnumerable:

An enumerable of objects which represent buttons. When null, the value of StandardButtons will define which button items are presented.

See Also

ButtonItemsClipboardText

Gets or sets the text used to represent the ButtonItems when copied to the clipboard.

public string? ButtonItemsClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the individual items of ButtonItems; e.g., button labels will be used as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

ButtonItemsHorizontalAlignment

Gets or sets the horizontal alignment for the panel of ButtonItems.

public HorizontalAlignment ButtonItemsHorizontalAlignment { get; set; }

Property Value

HorizontalAlignment:

One of the HorizontalAlignment values. The default value is Right.

ButtonStyle

Gets or sets the Style applied to buttons.

public Style ButtonStyle { get; set; }

Property Value

Style:

A Style.

CanExpand

Gets a value indicating whether content can be expanded, typically showing the ExpandedInformationContent.

public bool CanExpand { get; }

Property Value

bool:

true if expansion is available; otherwise, false.

CheckBoxContent

Gets or sets the content for the checkbox.

public object? CheckBoxContent { get; set; }

Property Value

object:

An object that contains the check box content.

Remarks

The default template will only display the check box if this property is populated.

See Also

CheckBoxContentClipboardText

Gets or sets the text used to represent the CheckBoxContent when copied to the clipboard.

public string? CheckBoxContentClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the CheckBoxContent; e.g., string-based content will be used directly as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

CheckBoxContentStringFormat

Gets or sets the format used to display the CheckBoxContent content as a string. This arises only when no template is available.

public string CheckBoxContentStringFormat { get; set; }

Property Value

string:

A string.

CheckBoxContentTemplate

Gets or sets the template used to display the CheckBoxContent.

public DataTemplate CheckBoxContentTemplate { get; set; }

Property Value

DataTemplate:

A DataTemplate used to display the CheckBoxContent.

CheckBoxContentTemplateSelector

Gets or sets the DataTemplateSelector to use for CheckBoxContent.

public DataTemplateSelector CheckBoxContentTemplateSelector { get; set; }

Property Value

DataTemplateSelector:

The DataTemplateSelector to use for CheckBoxContent.

CloseResult

Gets or sets the result for the prompt if it is closed without an explicit response.

public UserPromptStandardResult? CloseResult { get; set; }

Property Value

UserPromptStandardResult?:

One of the UserPromptStandardResult values, or null if an explicit result has not been defined and could not be inferred from StandardButtons. The default value is null.

ContentClipboardText

Gets or sets the text used to represent the Content when copied to the clipboard.

public string? ContentClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the Content; e.g., string-based content will be used directly as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

ContentMaxHeight

Gets or sets the maximum height constraint of the Content

[TypeConverter(typeof(LengthConverter))]
public double ContentMaxHeight { get; set; }

Property Value

double:

A double value. The default value is PositiveInfinity.

Remarks

The maximum height of the content, in device-independent units (1/96th inch per unit). The default value is PositiveInfinity. This value can be any value equal to or greater than 0.0. PositiveInfinity is also valid.

ContentMaxWidth

Gets or sets the maximum width constraint of the Content

[TypeConverter(typeof(LengthConverter))]
public double ContentMaxWidth { get; set; }

Property Value

double:

A double value. The default value is PositiveInfinity.

Remarks

The maximum width of the content, in device-independent units (1/96th inch per unit). The default value is PositiveInfinity. This value can be any value equal to or greater than 0.0. PositiveInfinity is also valid.

CornerRadius

Gets or sets the CornerRadius applied to the control.

public CornerRadius CornerRadius { get; set; }

Property Value

CornerRadius:

A CornerRadius.

DefaultResult

Gets or sets the default result for the prompt.

public UserPromptStandardResult DefaultResult { get; set; }

Property Value

UserPromptStandardResult:

One of the UserPromptStandardResult values.

ExpandedInformationCollapsedHeaderText

Gets or sets the text displayed as the header for ExpandedInformationContent when IsExpanded is false.

public string? ExpandedInformationCollapsedHeaderText { get; set; }

Property Value

string:

A string that will be used as the content for the header.

Remarks

Text supports access keys.

See Also

ExpandedInformationContent

Gets or sets the content for the expanded information.

public object? ExpandedInformationContent { get; set; }

Property Value

object:

An object that contains the expanded information content.

ExpandedInformationContentClipboardText

Gets or sets the text used to represent the ExpandedInformationContent when copied to the clipboard.

public string? ExpandedInformationContentClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the ExpandedInformationContent; e.g., string-based content will be used directly as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

ExpandedInformationContentStringFormat

Gets or sets the format used to display the ExpandedInformationContent content as a string. This arises only when no template is available.

public string ExpandedInformationContentStringFormat { get; set; }

Property Value

string:

A string.

ExpandedInformationContentTemplate

Gets or sets the template used to display the ExpandedInformationContent.

public DataTemplate ExpandedInformationContentTemplate { get; set; }

Property Value

DataTemplate:

A DataTemplate used to display the ExpandedInformationContent.

ExpandedInformationContentTemplateSelector

Gets or sets the DataTemplateSelector to use for ExpandedInformationContent.

public DataTemplateSelector ExpandedInformationContentTemplateSelector { get; set; }

Property Value

DataTemplateSelector:

The DataTemplateSelector to use for ExpandedInformationContent.

ExpandedInformationExpandedHeaderText

Gets or sets the text displayed as the header for ExpandedInformationContent when IsExpanded is true.

public string? ExpandedInformationExpandedHeaderText { get; set; }

Property Value

string:

A string that will be used as the content for the header.

Remarks

Text supports access keys.

See Also

Gets or sets the content for the footer.

public object? Footer { get; set; }

Property Value

object:

An object that contains the footer content.

FooterClipboardText

Gets or sets the text used to represent the Footer when copied to the clipboard.

public string? FooterClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the Footer; e.g., string-based content will be used directly as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

FooterImageSource

Gets or sets the source of an image to be displayed in the footer.

public ImageSource? FooterImageSource { get; set; }

Property Value

ImageSource:

An ImageSource.

FooterStringFormat

Gets or sets the format used to display the Footer content as a string. This arises only when no template is available.

public string FooterStringFormat { get; set; }

Property Value

string:

A string.

FooterTemplate

Gets or sets the template used to display the Footer.

public DataTemplate FooterTemplate { get; set; }

Property Value

DataTemplate:

A DataTemplate used to display the Footer.

FooterTemplateSelector

Gets or sets the DataTemplateSelector to use for the Footer.

public DataTemplateSelector FooterTemplateSelector { get; set; }

Property Value

DataTemplateSelector:

The DataTemplateSelector to use for the Footer.

HasAlignedHeader

Gets a value indicating whether the status image and header are aligned.

public bool HasAlignedHeader { get; }

Property Value

bool:

true if status image and header are aligned; otherwise, false. The default value is false.

HasCheckBoxContent

Gets a value indicating whether CheckBoxContent has a non-null value.

public bool HasCheckBoxContent { get; }

Property Value

bool:

true if CheckBoxContent has a non-null value; otherwise, false. The default value is false.

HasExpandedInformationContent

Gets a value indicating whether ExpandedInformationContent has a non-null value.

public bool HasExpandedInformationContent { get; }

Property Value

bool:

true if ExpandedInformationContent has a non-null value; otherwise, false. The default value is false.

HasFooter

Gets a value indicating whether Footer has a non-null value.

public bool HasFooter { get; }

Property Value

bool:

true if Footer has a non-null value; otherwise, false. The default value is false.

HasFooterImage

Gets a value indicating whether FooterImageSource has a non-null value.

public bool HasFooterImage { get; }

Property Value

bool:

true if FooterImageSource has a non-null value; otherwise, false. The default value is false.

HasStatusImage

Gets a value indicating whether StatusImageSource has a non-null value.

public bool HasStatusImage { get; }

Property Value

bool:

true if StatusImageSource has a non-null value; otherwise, false. The default value is false.

HeaderBackground

Gets or sets the brush used for the background of the header.

public Brush? HeaderBackground { get; set; }

Property Value

Brush:

A Brush for the header background.

HeaderBorderBrush

Gets or sets the brush used for the border of the header.

public Brush? HeaderBorderBrush { get; set; }

Property Value

Brush:

A Brush for the header border.

HeaderBorderThickness

Gets or sets the thickness of header border.

public Thickness HeaderBorderThickness { get; set; }

Property Value

Thickness:

A Thickness for the header border.

HeaderClipboardText

Gets or sets the text used to represent the Header when copied to the clipboard.

public string? HeaderClipboardText { get; set; }

Property Value

string:

A string value. The default value is null. When null, an attempt will be made to resolve the text from the Header; e.g., string-based content will be used directly as the clipboard text.

Remarks

Set this value when the appropriate clipboard text cannot be automatically resolved.

HeaderFontSize

Gets or sets the size of the font used for the header.

public double HeaderFontSize { get; set; }

Property Value

double:

The size of the font.

HeaderForeground

Gets or sets the brush used for the header.

public Brush? HeaderForeground { get; set; }

Property Value

Brush:

A Brush for the header.

HelpCommand

Gets or sets the command associated with the Help button.

public ICommand? HelpCommand { get; set; }

Property Value

ICommand:

An ICommand. The default value is Help.

See Also

HelpCommandParameter

Gets or sets the parameter passed to the HelpCommand.

public object? HelpCommandParameter { get; set; }

Property Value

object:

An object. The default value is null.

HorizontalScrollBarVisibility

Gets or sets a value indicating whether a horizontal scrollbar is shown for the content.

public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }

Property Value

ScrollBarVisibility:

One of the ScrollBarVisibility values. The default value is Disabled.

See Also

IsAnimationEnabled

Gets or sets whether animations are enabled for an element, when supported.

public bool IsAnimationEnabled { get; set; }

Property Value

bool:

true if animations are enabled; otherwise, false. The default value is true.

Remarks

This property is ignored when the current environment does not support animation.

IsChecked

Gets or sets if CheckBoxContent is checked.

public bool IsChecked { get; set; }

Property Value

bool:

true if CheckBoxContent is checked; otherwise, false.

See Also

IsExpanded

Gets or sets if ExpandedInformationContent is expanded.

public bool IsExpanded { get; set; }

Property Value

bool:

true if ExpandedInformationContent is expanded; otherwise, false.

Result

Gets or sets the explicit result for the prompt.

public object? Result { get; set; }

Property Value

object:

One of the UserPromptStandardResult values, null, or any object which represents a custom result. When defined for a button that is invoked for the response, the result will be based on the ButtonResultProperty attached property. Otherwise for custom buttons, the result must be manually assigned. The value is null if a result has not been provided.

StandardButtons

Gets or sets a standard button combination for the user prompt.

public UserPromptStandardButtons StandardButtons { get; set; }

Property Value

UserPromptStandardButtons:

One of the UserPromptStandardButtons values. The default value is OK.

Remarks

This property is ignored when ButtonItems is explicitly defined.

See Also

StandardStatusImage

Gets or sets a standard status image for the user prompt.

public UserPromptStandardImage StandardStatusImage { get; set; }

Property Value

UserPromptStandardImage:

One of the UserPromptStandardImage values. The default value is None.

Remarks

This property is ignored when StatusImageSource is explicitly defined.

See Also

StatusImageSource

Gets or sets the source of the status image.

public ImageSource StatusImageSource { get; set; }

Property Value

ImageSource:

An ImageSource.

See Also

SystemSound

Gets or sets the SystemSound to be played when the prompt is displayed.

public SystemSound SystemSound { get; set; }

Property Value

SystemSound:

A SystemSound or null if a default sound should be played based on the current value of StandardStatusImage. The default value is null.

TrayBackground

Gets or sets the background brush used for the tray elements.

public Brush? TrayBackground { get; set; }

Property Value

Brush:

A Brush for the background in the tray elements.

TrayForeground

Gets or sets the foreground brush used for the tray elements.

public Brush? TrayForeground { get; set; }

Property Value

Brush:

A Brush for the foreground in the tray elements.

VerticalScrollBarVisibility

Gets or sets a value indicating whether a vertical scrollbar is shown for the content.

public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }

Property Value

ScrollBarVisibility:

One of the ScrollBarVisibility values. The default value is Auto.

See Also

Methods

GetButtonClipboardText(DependencyObject)

Gets the value of the ButtonClipboardText attached property for the specified object.

[AttachedPropertyBrowsableForChildren(IncludeDescendants = true)]
public static string? GetButtonClipboardText(DependencyObject obj)
Parameter Type Description
obj DependencyObject

The object from which the property value is read.

Returns

string:

The object's value.

See Also

GetButtonResult(DependencyObject)

Gets the value of the ButtonResult attached property for the specified object.

[AttachedPropertyBrowsableForChildren(IncludeDescendants = true)]
public static UserPromptStandardResult GetButtonResult(DependencyObject obj)
Parameter Type Description
obj DependencyObject

The object from which the property value is read.

Returns

UserPromptStandardResult:

The object's value.

See Also

OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

public override void OnApplyTemplate()

OnCreateAutomationPeer()

Creates an appropriate UserPromptControlAutomationPeer for this control.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

A new instance of UserPromptControlAutomationPeer.

SetButtonClipboardText(DependencyObject, string?)

Sets the value of the ButtonClipboardText attached property to the specified object.

public static void SetButtonClipboardText(DependencyObject obj, string? value)
Parameter Type Description
obj DependencyObject

The object to which the attached property is written.

value string

The value to set.

See Also

SetButtonResult(DependencyObject, UserPromptStandardResult)

Sets the value of the ButtonResult attached property to the specified object.

public static void SetButtonResult(DependencyObject obj, UserPromptStandardResult value)
Parameter Type Description
obj DependencyObject

The object to which the attached property is written.

value UserPromptStandardResult

The value to set.

See Also

Events

Responding

Occurs when a response is being submitted to the user prompt.

public event EventHandler<UserPromptResponseEventArgs>? Responding

Event Type

EventHandler<UserPromptResponseEventArgs>

Fields

ButtonClipboardTextProperty

Identifies the ButtonClipboardText dependency property. This field is read-only.

public static readonly DependencyProperty ButtonClipboardTextProperty

ButtonItemsClipboardTextProperty

Identifies the ButtonItemsClipboardText dependency property.

public static readonly DependencyProperty ButtonItemsClipboardTextProperty

ButtonItemsHorizontalAlignmentProperty

Identifies the ButtonItemsHorizontalAlignment dependency property.

public static readonly DependencyProperty ButtonItemsHorizontalAlignmentProperty

ButtonItemsProperty

Identifies the ButtonItems dependency property.

public static readonly DependencyProperty ButtonItemsProperty

ButtonResultProperty

Identifies the ButtonResult dependency property. This field is read-only.

public static readonly DependencyProperty ButtonResultProperty

ButtonStyleProperty

Identifies the ButtonStyle dependency property.

public static readonly DependencyProperty ButtonStyleProperty

CanExpandProperty

Identifies the read-only CanExpand dependency property.

public static readonly DependencyProperty CanExpandProperty

CheckBoxContentClipboardTextProperty

Identifies the CheckBoxContentClipboardText dependency property.

public static readonly DependencyProperty CheckBoxContentClipboardTextProperty

CheckBoxContentProperty

Identifies the CheckBoxContent dependency property.

public static readonly DependencyProperty CheckBoxContentProperty

CheckBoxContentStringFormatProperty

Identifies the CheckBoxContentStringFormat dependency property.

public static readonly DependencyProperty CheckBoxContentStringFormatProperty

CheckBoxContentTemplateProperty

Identifies the CheckBoxContentTemplate dependency property.

public static readonly DependencyProperty CheckBoxContentTemplateProperty

CheckBoxContentTemplateSelectorProperty

Identifies the CheckBoxContentTemplateSelector dependency property.

public static readonly DependencyProperty CheckBoxContentTemplateSelectorProperty

CloseResultProperty

Identifies the CloseResult dependency property.

public static readonly DependencyProperty CloseResultProperty

ContentClipboardTextProperty

Identifies the ContentClipboardText dependency property.

public static readonly DependencyProperty ContentClipboardTextProperty

ContentMaxHeightProperty

Identifies the ContentMaxHeight dependency property.

public static readonly DependencyProperty ContentMaxHeightProperty

ContentMaxWidthProperty

Identifies the ContentMaxWidth dependency property.

public static readonly DependencyProperty ContentMaxWidthProperty

CornerRadiusProperty

Identifies the CornerRadius dependency property.

public static readonly DependencyProperty CornerRadiusProperty

DefaultResultProperty

Identifies the DefaultResult dependency property.

public static readonly DependencyProperty DefaultResultProperty

ExpandedInformationCollapsedHeaderTextProperty

Identifies the ExpandedInformationCollapsedHeaderText dependency property.

public static readonly DependencyProperty ExpandedInformationCollapsedHeaderTextProperty

ExpandedInformationContentClipboardTextProperty

Identifies the ExpandedInformationContentClipboardText dependency property.

public static readonly DependencyProperty ExpandedInformationContentClipboardTextProperty

ExpandedInformationContentProperty

Identifies the ExpandedInformationContent dependency property.

public static readonly DependencyProperty ExpandedInformationContentProperty

ExpandedInformationContentStringFormatProperty

Identifies the ExpandedInformationContentStringFormat dependency property.

public static readonly DependencyProperty ExpandedInformationContentStringFormatProperty

ExpandedInformationContentTemplateProperty

Identifies the ExpandedInformationContentTemplate dependency property.

public static readonly DependencyProperty ExpandedInformationContentTemplateProperty

ExpandedInformationContentTemplateSelectorProperty

Identifies the ExpandedInformationContentTemplateSelector dependency property.

public static readonly DependencyProperty ExpandedInformationContentTemplateSelectorProperty

ExpandedInformationExpandedHeaderTextProperty

Identifies the ExpandedInformationExpandedHeaderText dependency property.

public static readonly DependencyProperty ExpandedInformationExpandedHeaderTextProperty

FooterClipboardTextProperty

Identifies the FooterClipboardText dependency property.

public static readonly DependencyProperty FooterClipboardTextProperty

FooterImageSourceProperty

Identifies the FooterImageSource dependency property.

public static readonly DependencyProperty FooterImageSourceProperty

FooterProperty

Identifies the Footer dependency property.

public static readonly DependencyProperty FooterProperty

FooterStringFormatProperty

Identifies the FooterStringFormat dependency property.

public static readonly DependencyProperty FooterStringFormatProperty

FooterTemplateProperty

Identifies the FooterTemplate dependency property.

public static readonly DependencyProperty FooterTemplateProperty

FooterTemplateSelectorProperty

Identifies the FooterTemplateSelector dependency property.

public static readonly DependencyProperty FooterTemplateSelectorProperty

HasAlignedHeaderProperty

Identifies the read-only HasAlignedHeader dependency property.

public static readonly DependencyProperty HasAlignedHeaderProperty

HasCheckBoxContentProperty

Identifies the read-only HasCheckBoxContent dependency property.

public static readonly DependencyProperty HasCheckBoxContentProperty

HasExpandedInformationContentProperty

Identifies the read-only HasExpandedInformationContent dependency property.

public static readonly DependencyProperty HasExpandedInformationContentProperty

HasFooterImageProperty

Identifies the read-only HasFooterImage dependency property.

public static readonly DependencyProperty HasFooterImageProperty

HasFooterProperty

Identifies the read-only HasFooter dependency property.

public static readonly DependencyProperty HasFooterProperty

HasStatusImageProperty

Identifies the read-only HasStatusImage dependency property.

public static readonly DependencyProperty HasStatusImageProperty

HeaderBackgroundProperty

Identifies the HeaderBackground dependency property.

public static readonly DependencyProperty HeaderBackgroundProperty

HeaderBorderBrushProperty

Identifies the HeaderBorderBrush dependency property.

public static readonly DependencyProperty HeaderBorderBrushProperty

HeaderBorderThicknessProperty

Identifies the HeaderBorderThickness dependency property.

public static readonly DependencyProperty HeaderBorderThicknessProperty

HeaderClipboardTextProperty

Identifies the HeaderClipboardText dependency property.

public static readonly DependencyProperty HeaderClipboardTextProperty

HeaderFontSizeProperty

Identifies the HeaderFontSize dependency property.

public static readonly DependencyProperty HeaderFontSizeProperty

HeaderForegroundProperty

Identifies the HeaderForeground dependency property.

public static readonly DependencyProperty HeaderForegroundProperty

HelpCommandParameterProperty

Identifies the HelpCommandParameter dependency property.

public static readonly DependencyProperty HelpCommandParameterProperty

HelpCommandProperty

Identifies the HelpCommand dependency property.

public static readonly DependencyProperty HelpCommandProperty

HorizontalScrollBarVisibilityProperty

Identifies the HorizontalScrollBarVisibility dependency property.

public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty

IsAnimationEnabledProperty

Identifies the IsAnimationEnabled dependency property.

public static readonly DependencyProperty IsAnimationEnabledProperty

IsCheckedProperty

Identifies the IsChecked dependency property.

public static readonly DependencyProperty IsCheckedProperty

IsExpandedProperty

Identifies the IsExpanded dependency property.

public static readonly DependencyProperty IsExpandedProperty

ResultProperty

Identifies the Result dependency property.

public static readonly DependencyProperty ResultProperty

StandardButtonsProperty

Identifies the StandardButtons dependency property.

public static readonly DependencyProperty StandardButtonsProperty

StandardStatusImageProperty

Identifies the StandardStatusImage dependency property.

public static readonly DependencyProperty StandardStatusImageProperty

StatusImageSourceProperty

Identifies the StatusImageSource dependency property.

public static readonly DependencyProperty StatusImageSourceProperty

SystemSoundProperty

Identifies the SystemSound dependency property.

public static readonly DependencyProperty SystemSoundProperty

TrayBackgroundProperty

Identifies the TrayBackground dependency property.

public static readonly DependencyProperty TrayBackgroundProperty

TrayForegroundProperty

Identifies the TrayForeground dependency property.

public static readonly DependencyProperty TrayForegroundProperty

VerticalScrollBarVisibilityProperty

Identifies the VerticalScrollBarVisibility dependency property.

public static readonly DependencyProperty VerticalScrollBarVisibilityProperty