MaterialDesignXaml.DialogsHelper 1.0.0

Show, close material dialogs, dialog identifier.

There is a newer version of this package available.
See the version list below for details.
Install-Package MaterialDesignXaml.DialogsHelper -Version 1.0.0
dotnet add package MaterialDesignXaml.DialogsHelper --version 1.0.0
<PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MaterialDesignXaml.DialogsHelper --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MaterialDesignXaml.DialogsHelper

MVVM Example:

Main ViewModel:

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

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

		string name = await this.Show<string>(new TestDialog(this));

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

MainWindow View:

<Window ...>

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

    <materialDesign:DialogHost Identifier="{Binding Identifier}">
	
        <Button Content="Open dialog"
                Command="{Binding OpenDialogCommand}"
                Height="50"
                Width="100"/>
				
    </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>

MaterialDesignXaml.DialogsHelper

MVVM Example:

Main ViewModel:

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

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

		string name = await this.Show<string>(new TestDialog(this));

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

MainWindow View:

<Window ...>

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

    <materialDesign:DialogHost Identifier="{Binding Identifier}">
	
        <Button Content="Open dialog"
                Command="{Binding OpenDialogCommand}"
                Height="50"
                Width="100"/>
				
    </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>

Release Notes

Show, close material dialogs, dialog identifier.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3 35 12/9/2019
1.0.2 841 5/12/2019
1.0.1 185 5/6/2019
1.0.0 1,028 9/10/2018