MaterialDesignXaml.DialogsHelper 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MaterialDesignXaml.DialogsHelper --version 1.0.1
NuGet\Install-Package MaterialDesignXaml.DialogsHelper -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MaterialDesignXaml.DialogsHelper --version 1.0.1
#r "nuget: MaterialDesignXaml.DialogsHelper, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MaterialDesignXaml.DialogsHelper as a Cake Addin
#addin nuget:?package=MaterialDesignXaml.DialogsHelper&version=1.0.1

// Install MaterialDesignXaml.DialogsHelper as a Cake Tool
#tool nuget:?package=MaterialDesignXaml.DialogsHelper&version=1.0.1

MaterialDesignXaml.DialogsHelper

Example

MVVM Example:

Main ViewModel:

class MainWindowVM : IDialogIdentifier
{
	public string Identifier => "RootDialog";

	/// <summary>
	/// DelegateCommand - DevExpressMVVM.
	/// </summary>
	public ICommand OpenDialogCommand => new DelegateCommand(async () =>
	{
		//...any work

		string name = await this.ShowAsync<string>(new TestDialog(this), () => System.Console.WriteLine("Hi"), () => System.Console.WriteLine("Bye"));

		MessageBox.Show($"Your name: {name}");
	});

	/// <summary>
	/// DelegateCommand - DevExpressMVVM.
	/// </summary>
	public ICommand Open2SecDialogCommand => new DelegateCommand(async () =>
	{
		await this.ShowAsync("This dialog closes within 2 seconds.", async () =>
		{
			await Task.Delay(2000);

			this.Close();
		});
	});

	/// <summary>
	/// DelegateCommand - DevExpressMVVM.
	/// </summary>
	public ICommand OpenMessageBox => new DelegateCommand(async () =>
	{
		//...any work

		var result = await this.ShowMessageBoxAsync("What you'll press?", MaterialMessageBoxButtons.All);

		await this.ShowMessageBoxAsync($"You pressed: {result}", MaterialMessageBoxButtons.Ok);
	});
}

MainWindow View:

<Window x:Class="Example.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Example"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:controls="clr-namespace:MaterialDesignXaml.DialogsHelper.Controls;assembly=MaterialDesignXaml.DialogsHelper"
        mc:Ignorable="d"
        Title="MainWindow" 
        Height="450" 
        Width="800">

    <Window.DataContext>
        <local:MainWindowVM/>
    </Window.DataContext>

    <Window.Resources>
        
        <Style TargetType="controls:DialogButton"> 
            <Setter Property="Margin" Value="2"/>
            <Setter Property="FontSize" Value="15"/>
        </Style>

        <Style TargetType="Button">
            <Setter Property="Height" Value="50"/>
            <Setter Property="Width" Value="150"/>
            <Setter Property="Margin" Value="5"/>
        </Style>
    </Window.Resources>

    <materialDesign:DialogHost Identifier="{Binding Identifier}">
        <StackPanel>
            <Button Content="Open dialog"
                    Command="{Binding OpenDialogCommand}"/>

            <Button Content="Open 2 sec dialog"
                    Command="{Binding Open2SecDialogCommand}"/>

            <Button Content="Open messagebox"
                    Command="{Binding OpenMessageBox}"/>
        </StackPanel>
    </materialDesign:DialogHost>

</Window>

TestDialog (UserControl):

public partial class TestDialog : UserControl
{
	public TestDialog(IDialogIdentifier identifier)
	{
		InitializeComponent();

		DataContext = new TestDialogVM(identifier);
	}
}

TestDialog ViewModel:

class TestDialogVM : IClosableDialog
{
	public TestDialogVM(IDialogIdentifier identifier)
	{
		Identifier = identifier;
	}

	/// <summary>
	/// Closing dialog.
	/// DelegateCommand - DevExpressMVVM.
	/// </summary>
	public ICommand CloseDialogCommand => new DelegateCommand<string>(name =>
	{
		//...any works
		this.Close(name); //closing with parameter = value
	});

	/// <summary>
	/// DialogHost owner.
	/// </summary>
	public IDialogIdentifier Identifier { get; set; }
}

TestDialog View:

<UserControl ...>

    <StackPanel>
        <TextBlock Text="Input your name"/>

        <TextBox Name="Name"/>

        <Button Content="Close dialog"
                Command="{Binding CloseDialogCommand}"
                CommandParameter="{Binding Text, ElementName=Name}"/>
    </StackPanel>

</UserControl>
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 935 11/1/2022
1.0.3 2,770 12/9/2019
1.0.2 1,689 5/12/2019
1.0.1 724 5/6/2019
1.0.0 1,966 9/10/2018

Show, close material dialogs, dialog identifier, message box.