Movere is an implementation of managed dialogs for Avalonia. Currently there are message dialogs, as well as open and save file dialogs, and a print dialog (based on System.Drawing.Printing
) is WIP.
To use Avalonia system dialog APIs, it's possible to simply register Movere dialogs with AppBuilder
:
- Import
Movere
namespace:
using Movere;
- Add
UseMovere
toAppBuilder
configuration. Example:
AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseMovere();
- Then use Avalonia system dialog APIs. Example:
var dialog = new OpenFileDialog();
var result = await dialog.ShowAsync(parent);
To simply use the dialogs (this example is for message dialogs, but it's similar for others):
- Create a dialog service for
Window
(owner):
var messageDialogService = new MessageDialogService(owner);
- Pass the service to View Model:
window.DataContext = new ViewModel(messageDialogService);
- Show dialog from View Model when you need to:
private Task ShowInfoAsync() =>
_messageDialogService.ShowMessageDialogAsync(
new MessageDialogOptions(
DialogIcon.Info,
"Message Dialog",
"Some info",
DialogResultSet.OK));
Available icons are:
DialogIcon.None
DialogIcon.Info
DialogIcon.Warning
DialogIcon.Error
To add your own icon, just create an instance of DialogIcon
and pass the resource string, e.g avares://My.App/Resources/Icons/MyIcon.png
.
Dialog results are extensible as well, and support localization.
- Maybe separate file explorer view into separate project.
- Improve styles for dialogs.
- Add tests.
- Print dialog.
- Eventually move file explorer logic to a separate project and create a file explorer application.
- File - Kiranshastry
- Folder - Smashicons