Interface IDialogViewModel
The DataContext and binding source for the dialog Window. Implement this interface or the derived abstract DialogViewModel to transport data from the view to the view model via binding. The IDialogViewModel will be the content of the dialog window. This means the corresponding DataTemplate can define e.g. an input form that can bind to the IDialogViewModel. Register a callback with the ResponseCallbackAsync property to process the DialogResult and the data of the IDialogViewModel.
Inherited Members
Namespace: BionicCode.Utilities.Net
Assembly: BionicCode.Utilities.Net.Wpf.dll
Syntax
public interface IDialogViewModel : IViewModel, IProgressReporter, IViewModelCommon, INotifyDataErrorInfo, IProgressReporterCommon, INotifyPropertyChanged
Remarks
It is recommended to extend the abstract class DialogViewModel instead as this class already implemented the dialog data handling logic. Also use the Dialog attached behavior as it handles the view logic. Just bind DialogDataContextProperty to an instance of DialogViewModel (or IDialogViewModel) and define a DataTemplate for each implementation of DialogViewModel.
Properties
| Improve this Doc View SourceDialogResult
The DialogResult of the user interaction.
Declaration
DialogResult DialogResult { get; set; }
Property Value
| Type | Description |
|---|---|
| DialogResult |
Message
The message for the dialog to show to the user.
Declaration
string Message { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
ResponseCallbackAsync
The asynchronous callback that is invoked during the dialog interaction. Use this callback as continuation of the interrupted flow, after the required data was collected by the dialog.
Declaration
Func<IDialogViewModel, Task> ResponseCallbackAsync { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<IDialogViewModel, Task> |
Remarks
When using the abstract class DialogViewModel this delegate is invoked when invoking the SendResponseAsyncCommand. The parameter of this callback is the original IDialogViewModel. The callback can access the DialogResult property to get the interaction result. The ResponseCallbackAsync makes the dialog interaction fire-and-forget as the IDialogViewModelProviderSource doesn't need to wait for the dialog to close and doesn't have to store a reference to the IDialogViewModel.
SendResponseAsyncCommand
ICommand that can be bound to the buttons of the dialog. The command parameter is a DialogResult.
Declaration
IAsyncRelayCommand<DialogResult> SendResponseAsyncCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand<DialogResult> |
Remarks
When using the abstract class DialogViewModel the SendResponseAsyncCommand sets the DialogResult property and invokes the ResponseCallbackAsync continuation callback. The parameter of this callback is the original IDialogViewModel. The callback can access the DialogResult property to get the interaction result. The ResponseCallbackAsync makes the dialog interaction fire-and-forget as the IDialogViewModelProviderSource doesn't need to wait for the dialog to close and doesn't have to store a reference to the IDialogViewModel.
Title
The title of the dialog Window
Declaration
string Title { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
TitleBarIcon
The icon to display in the title bar of the Window
Declaration
ImageSource TitleBarIcon { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageSource |
Events
| Improve this Doc View SourceInteractionCompleted
Event to signal that the interaction with the dialog is completed.
Declaration
event EventHandler InteractionCompleted
Event Type
| Type | Description |
|---|---|
| EventHandler |
Remarks
When extending the abstract class DialogViewModel (instead of the IDialogViewModel interface) together with the attached property DialogDataContextProperty raising this event will notify the Dialog attached behavior class to close the Window.
InteractionCompleting
Event is raised before InteractionCompleted event. Setting the property Cancel of the CancelEventArgs event argument to true will cancel the dialog close process.
Declaration
event EventHandler<CancelEventArgs> InteractionCompleting
Event Type
| Type | Description |
|---|---|
| EventHandler<CancelEventArgs> |