{"id":14965103,"url":"https://github.com/avaloniautils/dialoghost.avalonia","last_synced_at":"2026-05-03T19:07:23.965Z","repository":{"id":41465226,"uuid":"359513542","full_name":"AvaloniaUtils/DialogHost.Avalonia","owner":"AvaloniaUtils","description":"AvaloniaUI control that provides a simple way to display a dialog with information or prompt the user when information is needed","archived":false,"fork":false,"pushed_at":"2025-01-21T17:44:20.000Z","size":518,"stargazers_count":295,"open_issues_count":3,"forks_count":19,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-11T12:36:57.896Z","etag":null,"topics":["avalonia","avaloniaui","c-sharp","c-sharp-library","control","dialogs","gui","multi-platform","mvvm","xaml"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AvaloniaUtils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-19T15:45:18.000Z","updated_at":"2025-04-30T20:48:44.000Z","dependencies_parsed_at":"2024-08-03T18:11:35.262Z","dependency_job_id":"5d600a62-5efd-4df7-9088-6bab6274845a","html_url":"https://github.com/AvaloniaUtils/DialogHost.Avalonia","commit_stats":{"total_commits":57,"total_committers":5,"mean_commits":11.4,"dds":0.1228070175438597,"last_synced_commit":"e6ede93d9f0dd3e213f8a0d78745ed5d9157e183"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaloniaUtils%2FDialogHost.Avalonia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaloniaUtils%2FDialogHost.Avalonia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaloniaUtils%2FDialogHost.Avalonia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaloniaUtils%2FDialogHost.Avalonia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AvaloniaUtils","download_url":"https://codeload.github.com/AvaloniaUtils/DialogHost.Avalonia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227612,"owners_count":22035669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avalonia","avaloniaui","c-sharp","c-sharp-library","control","dialogs","gui","multi-platform","mvvm","xaml"],"created_at":"2024-09-24T13:34:13.603Z","updated_at":"2026-05-03T19:07:23.952Z","avatar_url":"https://github.com/AvaloniaUtils.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DialogHost.Avalonia\n\nAvalonia DialogHost control that provides a simple way to display a dialog with information or prompt the user when\ninformation is required.\n\nDialogs in Avalonia have always been somewhat tricky. This implementation is designed to:\n\n* Provide correct styling\n* Allow any dialog to be constructed\n* Compatible with code-behind\n* Compatible with MVVM\n* Compatible with pure XAML\n* Work in applications with multiple windows\n\nDialogs *are asynchronous* so at some point you will have to deal with that in your code.\n\n## Getting started\n\n1. Install `DialogHost.Avalonia` [nuget package](https://www.nuget.org/packages/DialogHost.Avalonia/)\n   ```shell\n   dotnet add package DialogHost.Avalonia\n   ```\n2. Add DialogHostStyles element to your app styles in `App.axaml`. See the example of `App.axaml`:\n    ```xaml\n    \u003cApplication ...\n        xmlns:dialogHostAvalonia=\"clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia\"\n        ...\u003e\n        \n        ...\n        \u003cApplication.Styles\u003e\n            ...\n            \u003cdialogHostAvalonia:DialogHostStyles /\u003e\n        \u003c/Application.Styles\u003e\n        ...\n    \u003c/Application\u003e\n    ```\n    For version below `0.7` instead of `\u003cdialogHostAvalonia:DialogHostStyles /\u003e` use `StyleInclude`:\n    ```xaml\n    \u003cStyleInclude Source=\"avares://DialogHost.Avalonia/Styles.xaml\"/\u003e\n    ```\n\n3. Start using control\n\n## Using\n\nThe cornerstone of dialogs the DialogHost control. It’s a content control, meaning the underlying content over which the\npopup dialog will be displayed can be targeted; to a specific area of your app, or the entire Window content.\n\n```xaml\n\u003cWindow ...\n        xmlns:dialogHost=\"clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia\"\n        ...\n        Title=\"DialogHost.Demo\"\u003e\n    \u003cdialogHost:DialogHost CloseOnClickAway=\"True\"\u003e\n        \u003cdialogHost:DialogHost.DialogContent\u003e\n            \u003c!-- put your dialog content here--\u003e\n        \u003c/dialogHost:DialogHost.DialogContent\u003e\n        \u003c!-- put the content over which the dialog is shown here (e.g. your main window grid)--\u003e\n    \u003c/dialogHost:DialogHost\u003e\n\u003c/Window\u003e\n```\n\nWhen the dialog is open, the underlying content will be dimmed and disabled.\n\n![preview](https://github.com/AvaloniaUtils/DialogHost.Avalonia/raw/main/wiki/images/preview0.png)\n\n`DialogHost.DialogContent` (associated with `DialogHost.DialogContentTemplate`) is your typical XAML content object\nproperty for setting the content of your dialog. You can infer from this that you can use MVVM to bind content, but\nthere are multiple ways of populating the content, showing the dialog, closing the dialog, and processing responses.\n\n![previewGif](https://github.com/AvaloniaUtils/DialogHost.Avalonia/raw/main/wiki/images/preview.gif)\n\n### Alternative way\n\n- [HanumanInstitute.MvvmDialogs](https://github.com/mysteryx93/HanumanInstitute.MvvmDialogs/#avaloniadialoghost) allows the use of MVVM design in a simplified way, with DialogHost support. If you opt for that syntax, you do not need most of the documentation below, and the DialogHost container is injected to window automatically at runtime.\n\n---\n\n### Open Dialog Strategies\n\n#### OpenDialogCommand\n\n```xaml\nCommand=\"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=materialDesign:DialogHost}, Path=OpenDialogCommand}\"\n```\n\nICommand, typically used on buttons, where DialogContent can be set via CommandParameter.\n\n#### IsOpen\n\n```xaml\n\u003cdialogHost:DialogHost IsOpen=\"True\" /\u003e\n```\n\nDependency property, to be triggered from XAML, set from code-behind or via a binding. Content must be set in\nDialogHost.DialogContent.\n\n#### DialogHost.Show\n\n```c#\nDialogHost.Show(viewOrModel);\n```\n\nAsync/await based static API which can be used purely in code (for example from in a view model). Content can be passed\ndirectly to the dialog. Note that if you have multiple windows and multiple DialogHost instances you can set\nthe `DialogHost.Identifier` property, and provide the identifier to the .Show(...) method to help find the required\nDialogHost.\n\n\n---\n\n### Close Dialog Strategies\n\n#### CloseDialogCommand\n\nYou can bind to the DialogHost's OpenDialogCommand:\n\n```xaml\nCommand=\"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=materialDesign:DialogHost}, Path=CloseDialogCommand}\"\n```\n\nICommand, typically used on buttons inside the dialog, where the command parameter will be passed along to the dialog\nresponse.\n\n#### IsOpen\n\n```xaml\n\u003cdialogHost:DialogHost IsOpen=\"False\" /\u003e\n```\n\nDependency property, to be triggered from XAML, set from code-behind or via a binding.\n\n#### DialogSession.Close\n\nVia any of the methods for handling the opened event, you can get hold of the dialog session. This can be used to close\na dialog via code:\n\n```c#\nvar result = await DialogHost.Show(myContent, delegate(object sender, DialogOpenedEventArgs args)\n{\n    args.Session.Close(false);\n});\n```\n\nor getting DialogSession\n\n```c#\nDialogHost.GetDialogSession(\"DialogHost.Identifier here\")?.Close(false);\n```\n\n---\n\n### Handle Closing Event Strategies\n\nThe DialogClosingEventHandler delegate is key. It provides the parameter provided to DialogHost.CloseDialogCommand, and\nallows the pending close to be cancelled.\n\nThe following mechanisms allow handling of this event, via code-behind, MVVM practices, or just from the code API:\n\n#### DialogHost.DialogClosing\n\n```xaml\n\u003cdialogHost:DialogHost DialogClosing=\"DialogHost_OnDialogClosing\" /\u003e\n```\n\nBubbling RoutedEvent, which could be used in code-behind.\n\n#### DialogClosing.DialogClosingCallback\n\n```xaml\n\u003cdialogHost:DialogHost DialogClosingCallback=\"{Binding DialogClosingHandler}\" /\u003e\n```\n\nStandard dependency property which enables the DialogClosingEventHandler implementation to be bound, typically from a\nview model.\n\n#### DialogHost.Show\n\n```c#\nvar result = await DialogHost.Show(viewOrModel, ClosingEventHandler);\n```\n\nThe async response from this method returns the parameter provided when `DialogHost.CloseDialogCommand` was executed. As\npart of the `Show()` signature a `DialogClosingEventHandler` delegate can be provided to intercept the on-closing event,\njust prior to the close.\n\n### Multiple dialogs (0.10.0)\n\n```xaml\n\u003cdialogHost:DialogHost IsMultipleDialogsEnabled=\"True\" /\u003e\n```\n\nThan you can open multiple dialogs\n\n![multiple](https://github.com/AvaloniaUtils/DialogHost.Avalonia/raw/main/wiki/images/multiple.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favaloniautils%2Fdialoghost.avalonia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favaloniautils%2Fdialoghost.avalonia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favaloniautils%2Fdialoghost.avalonia/lists"}