Class ContentDialog
Dialogue displayed inside the application covering its internals, displaying some content.
public class ContentDialog : ContentControl, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, IAddChild
- Inheritance
-
ContentDialog
- Implements
- Inherited Members
Examples
<ContentPresenter x:Name="RootContentDialogPresenter" Grid.Row="0" />
var contentDialog = new ContentDialog(RootContentDialogPresenter);
contentDialog.SetCurrentValue(ContentDialog.TitleProperty, "Hello World");
contentDialog.SetCurrentValue(ContentControl.ContentProperty, "This is a message");
contentDialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, "Close this dialog");
await contentDialog.ShowAsync(cancellationToken);
var contentDialogService = new ContentDialogService();
contentDialogService.SetContentPresenter(RootContentDialogPresenter);
await _contentDialogService.ShowSimpleDialogAsync(
new SimpleContentDialogCreateOptions()
{
Title = "The cake?",
Content = "IS A LIE!",
PrimaryButtonText = "Save",
SecondaryButtonText = "Don't Save",
CloseButtonText = "Cancel"
}
);
Constructors
ContentDialog()
Initializes a new instance of the ContentDialog class.
public ContentDialog()
ContentDialog(ContentPresenter?)
Initializes a new instance of the ContentDialog class.
public ContentDialog(ContentPresenter? dialogHost)
Parameters
dialogHost
ContentPresenterDialogHost inside of which the dialogue will be placed. The new ContentDialog will replace the current Content.
Fields
ButtonClickedEvent
Identifies the ButtonClicked routed event.
public static readonly RoutedEvent ButtonClickedEvent
Field Value
CloseButtonAppearanceProperty
Identifies the CloseButtonAppearance dependency property.
public static readonly DependencyProperty CloseButtonAppearanceProperty
Field Value
CloseButtonIconProperty
Identifies the CloseButtonIcon dependency property.
public static readonly DependencyProperty CloseButtonIconProperty
Field Value
CloseButtonTextProperty
Identifies the CloseButtonText dependency property.
public static readonly DependencyProperty CloseButtonTextProperty
Field Value
ClosedEvent
Identifies the Closed routed event.
public static readonly RoutedEvent ClosedEvent
Field Value
ClosingEvent
Identifies the Closing routed event.
public static readonly RoutedEvent ClosingEvent
Field Value
DefaultButtonProperty
Identifies the DefaultButton dependency property.
public static readonly DependencyProperty DefaultButtonProperty
Field Value
DialogHeightProperty
Identifies the DialogHeight dependency property.
public static readonly DependencyProperty DialogHeightProperty
Field Value
DialogMarginProperty
Identifies the DialogMargin dependency property.
public static readonly DependencyProperty DialogMarginProperty
Field Value
DialogMaxHeightProperty
Identifies the DialogMaxHeight dependency property.
public static readonly DependencyProperty DialogMaxHeightProperty
Field Value
DialogMaxWidthProperty
Identifies the DialogMaxWidth dependency property.
public static readonly DependencyProperty DialogMaxWidthProperty
Field Value
DialogWidthProperty
Identifies the DialogWidth dependency property.
public static readonly DependencyProperty DialogWidthProperty
Field Value
IsFooterVisibleProperty
Identifies the IsFooterVisible dependency property.
public static readonly DependencyProperty IsFooterVisibleProperty
Field Value
IsPrimaryButtonEnabledProperty
Identifies the IsPrimaryButtonEnabled dependency property.
public static readonly DependencyProperty IsPrimaryButtonEnabledProperty
Field Value
IsSecondaryButtonEnabledProperty
Identifies the IsSecondaryButtonEnabled dependency property.
public static readonly DependencyProperty IsSecondaryButtonEnabledProperty
Field Value
OpenedEvent
Identifies the Opened routed event.
public static readonly RoutedEvent OpenedEvent
Field Value
PrimaryButtonAppearanceProperty
Identifies the PrimaryButtonAppearance dependency property.
public static readonly DependencyProperty PrimaryButtonAppearanceProperty
Field Value
PrimaryButtonIconProperty
Identifies the PrimaryButtonIcon dependency property.
public static readonly DependencyProperty PrimaryButtonIconProperty
Field Value
PrimaryButtonTextProperty
Identifies the PrimaryButtonText dependency property.
public static readonly DependencyProperty PrimaryButtonTextProperty
Field Value
SecondaryButtonAppearanceProperty
Identifies the SecondaryButtonAppearance dependency property.
public static readonly DependencyProperty SecondaryButtonAppearanceProperty
Field Value
SecondaryButtonIconProperty
Identifies the SecondaryButtonIcon dependency property.
public static readonly DependencyProperty SecondaryButtonIconProperty
Field Value
SecondaryButtonTextProperty
Identifies the SecondaryButtonText dependency property.
public static readonly DependencyProperty SecondaryButtonTextProperty
Field Value
TemplateButtonCommandProperty
Identifies the TemplateButtonCommand dependency property.
public static readonly DependencyProperty TemplateButtonCommandProperty
Field Value
TitleProperty
Identifies the Title dependency property.
public static readonly DependencyProperty TitleProperty
Field Value
TitleTemplateProperty
Identifies the TitleTemplate dependency property.
public static readonly DependencyProperty TitleTemplateProperty
Field Value
Properties
CloseButtonAppearance
Gets or sets the ControlAppearance to apply to the close button.
public ControlAppearance CloseButtonAppearance { get; set; }
Property Value
CloseButtonIcon
Gets or sets the SymbolRegular on the close button.
public IconElement? CloseButtonIcon { get; set; }
Property Value
CloseButtonText
Gets or sets the text to display on the close button.
public string CloseButtonText { get; set; }
Property Value
ContentPresenter
[Obsolete("ContentPresenter is deprecated. Please use DialogHost instead.")]
public ContentPresenter? ContentPresenter { get; set; }
Property Value
DefaultButton
Gets or sets a value that indicates which button on the dialog is the default action.
public ContentDialogButton DefaultButton { get; set; }
Property Value
DialogHeight
Gets or sets the height of the ContentDialog.
public double DialogHeight { get; set; }
Property Value
DialogHost
Gets or sets DialogHost inside of which the dialogue will be placed. The new ContentDialog will replace the current Content.
public ContentPresenter? DialogHost { get; set; }
Property Value
DialogMargin
Gets or sets the margin of the ContentDialog.
public Thickness DialogMargin { get; set; }
Property Value
DialogMaxHeight
Gets or sets the max height of the ContentDialog.
public double DialogMaxHeight { get; set; }
Property Value
DialogMaxWidth
Gets or sets the max width of the ContentDialog.
public double DialogMaxWidth { get; set; }
Property Value
DialogWidth
Gets or sets the width of the ContentDialog.
public double DialogWidth { get; set; }
Property Value
IsFooterVisible
Gets or sets a value indicating whether the footer buttons are visible.
public bool IsFooterVisible { get; set; }
Property Value
IsPrimaryButtonEnabled
Gets or sets a value indicating whether the ContentDialog primary button is enabled.
public bool IsPrimaryButtonEnabled { get; set; }
Property Value
IsSecondaryButtonEnabled
Gets or sets a value indicating whether the ContentDialog secondary button is enabled.
public bool IsSecondaryButtonEnabled { get; set; }
Property Value
PrimaryButtonAppearance
Gets or sets the ControlAppearance to apply to the primary button.
public ControlAppearance PrimaryButtonAppearance { get; set; }
Property Value
PrimaryButtonIcon
Gets or sets the SymbolRegular on the secondary button.
public IconElement? PrimaryButtonIcon { get; set; }
Property Value
PrimaryButtonText
Gets or sets the text to display on the primary button.
public string PrimaryButtonText { get; set; }
Property Value
SecondaryButtonAppearance
Gets or sets the ControlAppearance to apply to the secondary button.
public ControlAppearance SecondaryButtonAppearance { get; set; }
Property Value
SecondaryButtonIcon
Gets or sets the SymbolRegular on the primary button.
public IconElement? SecondaryButtonIcon { get; set; }
Property Value
SecondaryButtonText
Gets or sets the text to be displayed on the secondary button.
public string SecondaryButtonText { get; set; }
Property Value
Tcs
protected TaskCompletionSource<ContentDialogResult>? Tcs { get; set; }
Property Value
TemplateButtonCommand
Gets command triggered after clicking the button in the template.
public IRelayCommand TemplateButtonCommand { get; }
Property Value
Title
Gets or sets the title of the ContentDialog.
public object? Title { get; set; }
Property Value
TitleTemplate
Gets or sets the title template of the ContentDialog.
public DataTemplate? TitleTemplate { get; set; }
Property Value
Methods
Hide(ContentDialogResult)
Hides the dialog with result
public virtual void Hide(ContentDialogResult result = ContentDialogResult.None)
Parameters
result
ContentDialogResult
MeasureOverride(Size)
Called to remeasure a control.
protected override Size MeasureOverride(Size availableSize)
Parameters
availableSize
Size
Returns
- Size
The size of the control, up to the maximum specified by
constraint
.
OnButtonClick(ContentDialogButton)
Invoked when a ContentDialogButton is clicked.
protected virtual void OnButtonClick(ContentDialogButton button)
Parameters
button
ContentDialogButtonThe button that was clicked.
OnClosed(ContentDialogResult)
Occurs after ContentPresenter.Content = null
protected virtual void OnClosed(ContentDialogResult result)
Parameters
result
ContentDialogResult
OnLoaded()
Occurs after Loaded event
protected virtual void OnLoaded()
ShowAsync(CancellationToken)
Shows the dialog
public Task<ContentDialogResult> ShowAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken
Returns
Events
ButtonClicked
Occurs after the ContentDialogButton has been tapped.
public event TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> ButtonClicked
Event Type
Closed
Occurs after the dialog is closed.
public event TypedEventHandler<ContentDialog, ContentDialogClosedEventArgs> Closed
Event Type
Closing
Occurs after the dialog starts to close, but before it is closed and before the Closed event occurs.
public event TypedEventHandler<ContentDialog, ContentDialogClosingEventArgs> Closing
Event Type
Opened
Occurs after the dialog is opened.
public event TypedEventHandler<ContentDialog, RoutedEventArgs> Opened