All Projects → AvaloniaUtils → DialogHost.Avalonia

AvaloniaUtils / DialogHost.Avalonia

Licence: MIT license
AvaloniaUI control that provides a simple way to display a dialog with information or prompt the user when information is needed

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to DialogHost.Avalonia

Avalonia
A cross platform XAML framework for .NET
Stars: ✭ 12,588 (+13582.61%)
Mutual labels:  xaml, multi-platform, avalonia, avaloniaui
X-Filer-Cross-Platform
📁📁📁 X-Filer Cross-Platform - is a simple File Manager looking like popular browsers 📁📁📁
Stars: ✭ 19 (-79.35%)
Mutual labels:  xaml, avalonia, avaloniaui
Dock
A docking layout system.
Stars: ✭ 204 (+121.74%)
Mutual labels:  xaml, multi-platform, control
SvgToXaml
Svg to xaml conveter.
Stars: ✭ 45 (-51.09%)
Mutual labels:  xaml, avalonia, avaloniaui
SimpleWavSplitter
Split multi-channel WAV files into single channel WAV files.
Stars: ✭ 15 (-83.7%)
Mutual labels:  multi-platform, avalonia, avaloniaui
Panandzoom
Pan and zoom control for Avalonia.
Stars: ✭ 159 (+72.83%)
Mutual labels:  xaml, multi-platform, control
AvaloniaProgressRing
A progress ring for Avalonia -- based on ModernWPF's ProgressRing.
Stars: ✭ 63 (-31.52%)
Mutual labels:  control, avalonia, avaloniaui
Steamtools
🛠「Steam++」是一个开源跨平台的多功能Steam工具箱。
Stars: ✭ 4,458 (+4745.65%)
Mutual labels:  xaml, avalonia, avaloniaui
IconPacks.Browser
The Browser for all available Icon packages from MahApps.Metro.IconPacks
Stars: ✭ 74 (-19.57%)
Mutual labels:  xaml, avalonia, avaloniaui
ColorPicker
Customizable Color Picker control for WPF
Stars: ✭ 57 (-38.04%)
Mutual labels:  xaml, control
Handycontrols
Contains some simple and commonly used WPF controls based on HandyControl
Stars: ✭ 347 (+277.17%)
Mutual labels:  xaml, control
Toastnotifications
Toast notifications for WPF allows you to create and display rich notifications in WPF applications. It's highly configurable with set of built-in options like positions, behaviours, themes and many others. It's extendable, it gives you possibility to create custom and interactive notifications in simply manner.
Stars: ✭ 507 (+451.09%)
Mutual labels:  xaml, control
Avaloniabehaviors
Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
Stars: ✭ 96 (+4.35%)
Mutual labels:  xaml, multi-platform
Core2d
A multi-platform data driven 2D diagram editor.
Stars: ✭ 475 (+416.3%)
Mutual labels:  xaml, multi-platform
SimpleDialogs
💬 A simple framework to help displaying dialogs on a WPF app
Stars: ✭ 24 (-73.91%)
Mutual labels:  xaml, dialogs
Reactivehistory
Reactive undo/redo framework for .NET.
Stars: ✭ 82 (-10.87%)
Mutual labels:  xaml, multi-platform
ReactiveValidation
A small validation library for WPF and Avalonia which uses a fluent interface and allows display messages near controls in GUI with MVVM
Stars: ✭ 50 (-45.65%)
Mutual labels:  xaml, avalonia
Controlzex
Shared Controlz for WPF and ... more
Stars: ✭ 561 (+509.78%)
Mutual labels:  xaml, control
Aura.ui
A Library with a lot of Controls for AvaloniaUI
Stars: ✭ 114 (+23.91%)
Mutual labels:  xaml, control
Xamarin.Forms.Platform.Avalonia
Xamarin Forms platform implemented with Avalonia (A multi-platform .NET UI framework)
Stars: ✭ 36 (-60.87%)
Mutual labels:  multi-platform, avalonia

DialogHost.Avalonia

Avalonia DialogHost control that provides a simple way to display a dialog with information or prompt the user when information is required.

Dialogs in Avalonia have always been somewhat tricky. This implementation is designed to:

  • Provide correct styling
  • Allow any dialog to be constructed
  • Compatible with code-behind
  • Compatible with MVVM
  • Compatible with pure XAML
  • Work in applications with multiple windows

Dialogs are asynchronous so at some point you will have to deal with that in your code.

Getting started

  1. Install DialogHost.Avalonia nuget package
  2. Add DialogHost styles to your app in App.xaml. See the example of App.xaml:
<Application ...>
    ...
    <Application.Styles>
        ...
        <!-- This line \/ required -->
        <StyleInclude Source="avares://DialogHost.Avalonia/Styles.xaml"/>
        <!-- This line /\ required -->
    </Application.Styles>
    ...
</Application>
  1. Start using control

Using

The cornerstone of dialogs the DialogHost control. It’s a content control, meaning the underlying content over which the popup dialog will be displayed can be targeted; to a specific area of your app, or the entire Window content.

<Window ...
        xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
        ...
        Title="DialogHost.Demo">
    <dialogHost:DialogHost CloseOnClickAway="True">
        <dialogHost:DialogHost.DialogContent>
            <!-- put your dialog content here-->
        </dialogHost:DialogHost.DialogContent>
        <!-- put the content over which the dialog is shown here (e.g. your main window grid)-->
    </dialogHost:DialogHost>
</Window>

When the dialog is open, the underlying content will be dimmed and disabled.

preview

DialogHost.DialogContent (associated with DialogHost.DialogContentTemplate) is your typical XAML content object property for setting the content of your dialog. You can infer from this that you can use MVVM to bind content, but there are multiple ways of populating the content, showing the dialog, closing the dialog, and processing responses.

previewGif


Open Dialog Strategies

OpenDialogCommand

Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=materialDesign:DialogHost}, Path=OpenDialogCommand}"

ICommand, typically used on buttons, where DialogContent can be set via CommandParameter.

IsOpen

<dialogHost:DialogHost IsOpen="True" />

Dependency property, to be triggered from XAML, set from code-behind or via a binding. Content must be set in DialogHost.DialogContent.

DialogHost.Show

DialogHost.Show(viewOrModel);

Async/await based static API which can be used purely in code (for example from in a view model). Content can be passed directly to the dialog. Note that if you have multiple windows and multiple DialogHost instances you can set the DialogHost.Identifier property, and provide the identifier to the .Show(...) method to help find the required DialogHost.


Close Dialog Strategies

CloseDialogCommand

You can bind to the DialogHost's OpenDialogCommand:

Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=materialDesign:DialogHost}, Path=CloseDialogCommand}"

ICommand, typically used on buttons inside the dialog, where the command parameter will be passed along to the dialog response.

IsOpen

<dialogHost:DialogHost IsOpen="False" />

Dependency property, to be triggered from XAML, set from code-behind or via a binding.

DialogSession.Close

Via any of the methods for handling the opened event, you can get hold of the dialog session. This can be used to close a dialog via code:

var result = await DialogHost.Show(myContent, delegate(object sender, DialogOpenedEventArgs args)
{
    args.Session.Close(false);
});

or getting DialogSession

DialogHost.GetDialogSession("DialogHost.Identifier here")?.Close(false);

Handle Closing Event Strategies

The DialogClosingEventHandler delegate is key. It provides the parameter provided to DialogHost.CloseDialogCommand, and allows the pending close to be cancelled.

The following mechanisms allow handling of this event, via code-behind, MVVM practices, or just from the code API:

DialogHost.DialogClosing

<dialogHost:DialogHost DialogClosing="DialogHost_OnDialogClosing" />

Bubbling RoutedEvent, which could be used in code-behind.

DialogClosing.DialogClosingCallback

<dialogHost:DialogHost DialogClosingCallback="{Binding DialogClosingHandler}" />

Standard dependency property which enables the DialogClosingEventHandler implementation to be bound, typically from a view model.

DialogHost.Show

var result = await DialogHost.Show(viewOrModel, ClosingEventHandler);

The async response from this method returns the parameter provided when DialogHost.CloseDialogCommand was executed. As part of the Show() signature a DialogClosingEventHandler delegate can be provided to intercept the on-closing event, just prior to the close.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].