| Package | NuGet | MyGet |
|---|---|---|
| Movere | ||
| Movere.FileDialogs | ||
| Movere.Win32 |
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 storage provider APIs, it's possible to simply register Movere dialogs with AppBuilder:
- Import
Moverenamespace:
using Movere;- Add
UseMovereStorageProvidertoAppBuilderconfiguration. Example:
AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseMovereStorageProvider();- Then use Avalonia system dialog APIs. Example:
var options = new FilePickerOpenOptions()
{
...
};
var result = parent.StorageProvider.OpenFilePickerAsync(options);If using the old system dialogs APIs, the AppBuilder extension method is UseMovereSystemDialogs and an example is:
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 host for the
owner:
var dialogHost = new WindowDialogHost(owner);
// OR
var dialogHost = new OverlayDialogHost(owner);- Pass the host to the view model:
window.DataContext = new ViewModel(dialogHost);- Show dialog from the view model when you need to:
private Task ShowInfoAsync() =>
_dialogHost
.ShowMessageDialog(
new MessageDialogOptions((LocalizedString)"Message Dialog", "Some info")
{
Icon = AvaloniaDialogIcon.Info,
DialogResults = DialogResultSet.OK
}
);Available icons are:
DialogIcon.NoneAvaloniaDialogIcon.InfoAvaloniaDialogIcon.WarningAvaloniaDialogIcon.Error
To add your own icon, just call AvaloniaDialogIcon.TryCreate, passing 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