{"id":16495124,"url":"https://github.com/evaristocuesta/messagedialogmanagerlib","last_synced_at":"2025-09-19T06:31:05.876Z","repository":{"id":56022211,"uuid":"304975749","full_name":"evaristocuesta/MessageDialogManagerLib","owner":"evaristocuesta","description":"Library to easily use dialogs from a View Model in a Mahapps Metro App.","archived":false,"fork":false,"pushed_at":"2020-12-25T23:28:45.000Z","size":89,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-01T05:35:06.454Z","etag":null,"topics":["csharp","dialogs","mahapps-metro","mvvm","netframework","viewmodel","wpf"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/MessageDialogManagerLib/","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/evaristocuesta.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}},"created_at":"2020-10-17T21:54:27.000Z","updated_at":"2023-03-26T10:19:32.000Z","dependencies_parsed_at":"2022-08-15T11:40:14.039Z","dependency_job_id":null,"html_url":"https://github.com/evaristocuesta/MessageDialogManagerLib","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evaristocuesta%2FMessageDialogManagerLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evaristocuesta%2FMessageDialogManagerLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evaristocuesta%2FMessageDialogManagerLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evaristocuesta%2FMessageDialogManagerLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evaristocuesta","download_url":"https://codeload.github.com/evaristocuesta/MessageDialogManagerLib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233553762,"owners_count":18693317,"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":["csharp","dialogs","mahapps-metro","mvvm","netframework","viewmodel","wpf"],"created_at":"2024-10-11T14:27:54.640Z","updated_at":"2025-09-19T06:31:00.445Z","avatar_url":"https://github.com/evaristocuesta.png","language":"C#","readme":"# MessageDialogManagerLib\n[![NuGet](https://img.shields.io/nuget/v/MessageDialogManagerLib)](https://nuget.org/packages/MessageDialogManagerLib/) [![Downloads](https://img.shields.io/nuget/dt/MessageDialogManagerLib)](https://nuget.org/packages/MessageDialogManagerLib/) [![.NET Core](https://github.com/evaristocuesta/MessageDialogManagerLib/workflows/.NET%20Core/badge.svg)](https://github.com/evaristocuesta/MessageDialogManagerLib/actions) [![Languages](https://img.shields.io/github/languages/top/evaristocuesta/MessageDialogManagerLib)](https://github.com/evaristocuesta/MessageDialogManagerLib/) [![License](https://img.shields.io/github/license/evaristocuesta/MessageDialogManagerLib)](https://raw.githubusercontent.com/evaristocuesta/MessageDialogManagerLib/master/LICENSE) [![Author](https://img.shields.io/badge/author-Evaristo%20Cuesta-blue)](https://www.evaristocuesta.com/)\n\n**MessageDialogManagerLib** is a library to easily use dialogs from ViewModels in WPF Mahapps.Metro applications. This library uses [Mahapps.Metro](https://mahapps.com/) to show info, progress, ok/cancel or custom dialog. To show an open file dialog, this library uses Microsoft.Win32.OpenFileDialog, to show a save file dialog uses Microsoft.Win32.SaveFileDialog and to show a folder browser, this library uses [FolderBrowserEx](https://github.com/evaristocuesta/FolderBrowserEx).\n\nSupporting .NET Framework (4.5+) and .NET Core (3.0 and 3.1)\n\n## Table of contents\n\n  - [Introduction](#introduction)\n  - [Getting Started](#getting-started)\n  - [License](#license)\n  - [Credits](#credits)\n\n## Introduction\n\nIn both WPF .NET Framework and .NET Core applications we can use dialogs. The problem comes when you want to show a dialog from a ViewModel, especially when you want to test your ViewModel and dialogs block your tests. \n\nThe aim of this project is to offer a library with an interface to easily inject in your ViewModel. Your ViewModel will be independent from dialogs implementations and will be testable without blocks.  \n\n## Getting Started\n\nTo use this library, there are a few options:\n\n  - Download the [Github repository](https://github.com/evaristocuesta/MessageDialogManagerLib)\n  - Use the [MessageDialogManagerLib Nuget Package](https://nuget.org/packages/MessageDialogManagerLib/)\n\nTo use this library, the WPF application has to use [Mahapps.Metro](https://mahapps.com/).\n\nThe **MessageDialogManagerLib** uses the IMessageDialogManager interface.\n```csharp\npublic interface IMessageDialogManager\n{\n    /// \u003csummary\u003e\n    /// Shows a folder browser dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"initialPath\"\u003eSets the initial path of the dialog\u003c/param\u003e\n    /// \u003creturns\u003eReturns if a folder has been selected\u003c/returns\u003e\n    bool ShowFolderBrowser(string title, string initialPath, bool allowMultiSelect = false);\n\n    /// \u003csummary\u003e\n    /// Gets the selected folder\n    /// \u003c/summary\u003e\n    string FolderPath { get; set; }\n\n    /// \u003csummary\u003e\n    /// Shows a file browser dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"initialPath\"\u003eSets the initial path of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"filter\"\u003eSets a filter to show only the files that meet the filter\u003c/param\u003e\n    /// \u003creturns\u003eReturns if a file has been selected\u003c/returns\u003e\n    bool ShowFileBrowser(string title, string initialPath, string filter, bool allowMultiSelect = false);\n\n    /// \u003csummary\u003e\n    /// Gets the selected file\n    /// \u003c/summary\u003e\n    string FilePath { get; set; }\n\n    /// \u003csummary\u003e\n    /// Shows a save file dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"initialPath\"\u003eSets the initial path of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"fileName\"\u003eSets the file's name\u003c/param\u003e\n    /// \u003cparam name=\"defaultExt\"\u003eSets the default file's extension\u003c/param\u003e\n    /// \u003cparam name=\"filter\"\u003eSets the filter\u003c/param\u003e\n    /// \u003creturns\u003eReturns if a file has been saved\u003c/returns\u003e\n    bool ShowSaveFileDialog(string title, string initialPath, string fileName, \n        string defaultExt, string filter);\n\n    /// \u003csummary\u003e\n    /// Gets the file to save\n    /// \u003c/summary\u003e\n    string FilePathToSave { get; set; }\n\n    /// \u003csummary\u003e\n    /// Shows a ok and cancel dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"text\"\u003eSets the text of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// MessageDialogResult.OK if the user clicks OK in the dialog box;\n    /// otherwise, MessageDialogResult.Cancel.\n    Task\u003cMessageDialogResult\u003e ShowOkCancelDialogAsync(string text, string title);\n\n    /// \u003csummary\u003e\n    /// Shows a info dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"message\"\u003eSets the message of the dialog\u003c/param\u003e\n    /// \u003creturns\u003e\u003c/returns\u003e\n    Task ShowInfoDialogAsync(string title, string message);\n\n    /// \u003csummary\u003e\n    /// Shows a progress dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"title\"\u003eSets the title of the dialog\u003c/param\u003e\n    /// \u003cparam name=\"message\"\u003eSets the message of the dialog\u003c/param\u003e\n    /// \u003creturns\u003e\u003c/returns\u003e\n    Task ShowProgress(string title, string message);\n\n    /// \u003csummary\u003e\n    /// Updates the progress\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"progress\"\u003eSets de progress\u003c/param\u003e\n    void UpdateProgress(double progress);\n\n    /// \u003csummary\u003e\n    /// Updates the message progress\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"message\"\u003eSets the message progress\u003c/param\u003e\n    void UpdateMessageProgress(string message);\n\n    /// \u003csummary\u003e\n    /// Closes the progress dialog\n    /// \u003c/summary\u003e\n    /// \u003creturns\u003e\u003c/returns\u003e\n    Task CloseProgress();\n\n    /// \u003csummary\u003e\n    /// Shows a custom dialog\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"viewModel\"\u003eSets the viewmodel attached to the custom dialog\u003c/param\u003e\n    /// \u003creturns\u003e\u003c/returns\u003e\n    Task ShowDialogAsync(IDialogViewModel viewModel);\n}\n```\nTo use **MessageDialogManagerLib** in an application, you can follow this example code. There are others examples in the directory Samples of the solution. \n\n```csharp\nMessageDialogManagerMahapps messageDialogManager = new MessageDialogManagerMahapps(App.Current);\nMessageDialogResult result = \n                await messageDialogManager.ShowOkCancelDialogAsync(\n                    \"Ok Cancel Dialog\", \n                    \"This is a Ok Cancel Dialog\");\nif (result == MessageDialogResult.OK)\n    await messageDialogManager.ShowInfoDialogAsync(\"Result\", \"You select Ok\");\nelse\n    await messageDialogManager.ShowInfoDialogAsync(\"Result\", \"You select Cancel\");\n```\n\nIf you want to use the **MessageDialogManagerLib** library from a View Model, follow this example code. You can find the complete example in the directory Samples of the solution. \n\n```csharp\nusing CommandLibrary;\nusing MessageDialogManagerLib;\nusing System.Threading.Tasks;\nusing System.Windows.Input;\n\nnamespace NetFrameworkSample.ViewModel\n{\n    public class MainWindowViewModel\n    {\n        private readonly IMessageDialogManager _messageDialogManager;\n\n        public MainWindowViewModel(IMessageDialogManager messageDialogManager)\n        {\n            _messageDialogManager = messageDialogManager;\n            ShowOkCancelDialogCommand = new Command(\n                ShowOkCancelDialogCommandExecute, \n                ShowOkCancelDialogCommandCanExecute);\n        }\n\n        public ICommand ShowOkCancelDialogCommand { get; private set; }\n\n        private async void ShowOkCancelDialogCommandExecute()\n        {\n            MessageDialogResult result = \n                await _messageDialogManager.ShowOkCancelDialogAsync(\n                    \"Ok Cancel Dialog\", \n                    \"This is a Ok Cancel Dialog\");\n            if (result == MessageDialogResult.OK)\n                await _messageDialogManager.ShowInfoDialogAsync(\"Result\", \"You select Ok\");\n            else\n                await _messageDialogManager.ShowInfoDialogAsync(\"Result\", \"You select Cancel\");\n        }\n\n        private bool ShowOkCancelDialogCommandCanExecute()\n        {\n            return true;\n        }\n    }\n}\n```\n\n## License\n\nCopyright © 2020 Evaristo Cuesta \n\n**MessageDialogManagerLib** is provided as-is under the MIT license. For more information see [LICENSE](https://github.com/evaristocuesta/MessageDialogManagerLib/blob/master/LICENSE).\n\n## Credits\n\nThis project uses [Mahapps.Metro](https://mahapps.com/) and [FolderBrowserEx](https://github.com/evaristocuesta/FolderBrowserEx).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevaristocuesta%2Fmessagedialogmanagerlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevaristocuesta%2Fmessagedialogmanagerlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevaristocuesta%2Fmessagedialogmanagerlib/lists"}