Search Results for

    Show / Hide Table of Contents

    Class Dialog

    Attached behavior. Displays a Window based on an implementation of IDialogViewModel assigned to the attached property DialogDataContextProperty and a custom DataTemplate.

    Inheritance
    Object
    DispatcherObject
    DependencyObject
    Dialog
    Inherited Members
    DependencyObject.ClearValue(DependencyProperty)
    DependencyObject.ClearValue(DependencyPropertyKey)
    DependencyObject.CoerceValue(DependencyProperty)
    DependencyObject.Equals(Object)
    DependencyObject.GetHashCode()
    DependencyObject.GetLocalValueEnumerator()
    DependencyObject.GetValue(DependencyProperty)
    DependencyObject.InvalidateProperty(DependencyProperty)
    DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
    DependencyObject.ReadLocalValue(DependencyProperty)
    DependencyObject.SetCurrentValue(DependencyProperty, Object)
    DependencyObject.SetValue(DependencyProperty, Object)
    DependencyObject.SetValue(DependencyPropertyKey, Object)
    DependencyObject.ShouldSerializeProperty(DependencyProperty)
    DependencyObject.DependencyObjectType
    DependencyObject.IsSealed
    DispatcherObject.Dispatcher
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: BionicCode.Utilities.Net
    Assembly: BionicCode.Utilities.Net.Wpf.dll
    Syntax
    public class Dialog : DependencyObject
    Remarks

    This attached behavior will display a dialog Window using the View-model-first pattern.

    The IDialogViewModel instance bound to the DialogDataContextProperty will be assigned to the Content of the Window. To layout the content requires to define an implicit DataTemplate that targets the type of the IDialogViewModel implementation. Alternatively set the template for the ContentTemplate via a Style that targets Window and is assigned to the StyleProperty attached property. For more complex scenarios it is possible to assign a DataTemplateSelector to the DataTemplateSelectorProperty attached property.

    To define the attributes like title and icon of the dialog, set the corresponding values of the IDialogViewModel implementation. Dialog sets up a data binding to those properties, so that they can be dynamically changed by the view model.

    It is recommended to use and extend the abstract DialogViewModel, which provides the basic IDialogViewModel implementation and logic. It only needs to be extended to provide the required specific properties for the dialog's context.

    To show a dialog, simply assign an instance of IDialogViewModel to the attached property DialogDataContextProperty. A change of that property will automatically display a new dialog window. To each IDialogViewModel maps an instance of Window. It is recommended to bind the attached DialogDataContextProperty to a property of a view model class that implements INotifyPropertyChanged. This way it is very simple to display dialogs dynamically initiated by the view model i.e. the binding source of the attached DialogDataContextProperty property.

    To close a dialog, raise the InteractionCompleted event from the IDialogViewModel implementation e.g., by calling OnInteractionCompleted() or by invoking the SendResponseAsyncCommand (in case you followed the recommendation to extend DialogViewModel).

    Fields

    | Improve this Doc View Source

    DataTemplateSelectorProperty

    Attached property to set a DataTemplateSelector to use for the displayed dialog Window to display the content.

    Declaration
    public static readonly DependencyProperty DataTemplateSelectorProperty
    Field Value
    Type Description
    DependencyProperty
    | Improve this Doc View Source

    DialogDataContextProperty

    Attached property designed to bind to a view model property of type IDialogViewModel. A change of this property will trigger the Dialog to show a Window with the DataContext set to the IDialogViewModel instance of this property.

    Declaration
    public static readonly DependencyProperty DialogDataContextProperty
    Field Value
    Type Description
    DependencyProperty
    | Improve this Doc View Source

    IsClosableProperty

    Attached property that controls if the user is allowed to explicitly close the Window.

    Declaration
    public static readonly DependencyProperty IsClosableProperty
    Field Value
    Type Description
    DependencyProperty
    | Improve this Doc View Source

    IsModalProperty

    Attached property that controls if the Window is shown modal.

    Declaration
    public static readonly DependencyProperty IsModalProperty
    Field Value
    Type Description
    DependencyProperty
    | Improve this Doc View Source

    StyleProperty

    The attached Style property which holds the Style which should apply to the dialog. TargetType must be Window.

    Declaration
    public static readonly DependencyProperty StyleProperty
    Field Value
    Type Description
    DependencyProperty

    Methods

    | Improve this Doc View Source

    GetDataTemplateSelector(DependencyObject)

    Returns the DataTemplateSelector registered with the attachingElement.

    Declaration
    public static DataTemplateSelector GetDataTemplateSelector(DependencyObject attachingElement)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Returns
    Type Description
    DataTemplateSelector

    The DataTemplateSelector registered with the attachingElement.

    | Improve this Doc View Source

    GetDialogDataContext(DependencyObject)

    The getter for the attached DialogDataContextProperty property.

    Declaration
    public static IDialogViewModel GetDialogDataContext(DependencyObject attachingElement)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Returns
    Type Description
    IDialogViewModel

    The current associated IDialogViewModel.

    | Improve this Doc View Source

    GetIsClosable(DependencyObject)

    Get method of the attached property IsClosableProperty.

    Declaration
    public static bool GetIsClosable(DependencyObject attachingElement)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Returns
    Type Description
    Boolean

    true to allow the user to close the Window, otherwise false.

    | Improve this Doc View Source

    GetIsModal(DependencyObject)

    Get method of the attached property IsModalProperty.

    Declaration
    public static bool GetIsModal(DependencyObject attachingElement)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Returns
    Type Description
    Boolean

    true to show the Window modal, otherwise false.

    | Improve this Doc View Source

    GetStyle(DependencyObject)

    Get method of the attached property StyleProperty.

    Declaration
    public static Style GetStyle(DependencyObject attachingElement)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Returns
    Type Description
    Style

    The dialog's Style registered with the attachingElement.

    | Improve this Doc View Source

    SetDataTemplateSelector(DependencyObject, DataTemplateSelector)

    Set method of the attached DataTemplateSelectorProperty property.

    Declaration
    public static void SetDataTemplateSelector(DependencyObject attachingElement, DataTemplateSelector value)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    DataTemplateSelector value

    A DataTemplateSelector implementation for the window's content.

    | Improve this Doc View Source

    SetDialogDataContext(DependencyObject, IDialogViewModel)

    The setter for the attached DialogDataContextProperty property.

    Declaration
    public static void SetDialogDataContext(DependencyObject attachingElement, IDialogViewModel value)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    IDialogViewModel value

    An instance of IDialogViewModel.

    | Improve this Doc View Source

    SetIsClosable(DependencyObject, Boolean)

    Set method of the IsClosableProperty attached property.

    Declaration
    public static void SetIsClosable(DependencyObject attachingElement, bool value)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Boolean value

    true to allow the user to close the Window, otherwise false. The default is false.

    | Improve this Doc View Source

    SetIsModal(DependencyObject, Boolean)

    Set method of the IsModalProperty attached property.

    Declaration
    public static void SetIsModal(DependencyObject attachingElement, bool value)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Boolean value

    true to show the Window modal, otherwise false. The default is false.

    | Improve this Doc View Source

    SetStyle(DependencyObject, Style)

    Set method of the attached property StyleProperty.

    Declaration
    public static void SetStyle(DependencyObject attachingElement, Style value)
    Parameters
    Type Name Description
    DependencyObject attachingElement

    The attached FrameworkElement.

    Style value

    The Style for the dialog Window.

    | Improve this Doc View Source

    TryGetDialog(IDialogViewModel, out Window)

    Attempts to get the dialog Window of the associated IDialogViewModel instance.

    Declaration
    public static bool TryGetDialog(IDialogViewModel viewModel, out Window dialog)
    Parameters
    Type Name Description
    IDialogViewModel viewModel

    The associated data context of the dialog.

    Window dialog

    The Window instance associated with the viewModel.

    Returns
    Type Description
    Boolean

    true when a Window that maps to the viewModel exists, otherwise false.

    Extension Methods

    HelperExtensionsCommon.ToDictionary(Object)
    HelperExtensionsCommon.ToFlatDictionary(Object)
    HelperExtensions.TryFindVisualParentElement<TParent>(DependencyObject, out TParent)
    HelperExtensions.TryFindVisualParentElementByName<TChild>(DependencyObject, String, out TChild)
    HelperExtensions.TryFindVisualChildElement<TChild>(DependencyObject, out TChild)
    HelperExtensions.TryFindVisualChildElementByName<TChild>(DependencyObject, String, out TChild)
    HelperExtensions.EnumerateVisualChildElements<TChildren>(DependencyObject)

    See Also

    See advanced example
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX