• Stars
    star
    643
  • Rank 70,000 (Top 2 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library simplifying the concept of opening dialogs from a view model when using MVVM in WPF


MVVM Dialogs
MVVM Dialogs

Library simplifying the concept of opening dialogs from a view model when using MVVM in WPF.

This codebase is actively maintained but not actively developed. Pull requests with new features will have a very slim chance of getting merged. In many aspects this codebase is "done".

Please feel free to use the code, but refrain from having hopes that it has any aspirations of being anything more than it currently is.

Table of contents


Introduction

MVVM Dialogs is a library simplifying the concept of opening dialogs from a view model when using MVVM in WPF (Windows Presentation Framework). It enables the developer to easily write unit tests for view models in the same manner unit tests are written for other classes.

The library has built in support for the following dialogs:

  • Modal window
  • Non-modal window
  • Message box
  • Open file dialog
  • Save file dialog
  • Folder browser dialog

Usage

To open a modal window, decorate the view with the attached property DialogServiceViews.IsRegistered:

<UserControl
    x:Class="DemoApplication.Features.Dialog.Modal.Views.ModalDialogTabContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:md="https://github.com/fantasticfiasco/mvvm-dialogs"
    md:DialogServiceViews.IsRegistered="True">

  ...

</UserControl>

With the view registered the view model is now capable of opening a dialog using the interface IDialogService:

public class ModalDialogTabContentViewModel : INotifyPropertyChanged
{
    private readonly IDialogService dialogService;

    public ModalDialogTabContentViewModel(IDialogService dialogService)
    {
        this.dialogService = dialogService;
    }

    ...

    private void ShowDialog()
    {
        var dialogViewModel = new AddTextDialogViewModel();

        bool? success = dialogService.ShowDialog(this, dialogViewModel);
        if (success == true)
        {
            Texts.Add(dialogViewModel.Text);
        }
    }
}

Custom windows

Dialogs in WPF that don't inherit from Window are called custom dialogs. These custom dialogs are supported, but in order for DialogService to know how to interact with them, you will have to implement the IWindow interface.

Custom framework dialogs

MVVM Dialogs is by default opening the standard Windows message box or the open file dialog when asked to. This can however be changed by providing your own implementation of IFrameworkDialogFactory to DialogService.

More in the wiki

For more information regarding the concepts of MVVM Dialogs and extended samples on the subjects, please see the wiki.

Integration into other MVVM frameworks

For the benefit of all we aim to play nice with existing MVVM frameworks. Creating a new application can be daunting. Lots of decisions have to be made, and some mistakes are harder to correct than others. To help you on your way we've created a sample application using some of the popular MVVM frameworks existing today, to show you how you'd integrate MVVM Dialogs into that framework.

Currently the sample application is implemented using the following frameworks.

If your specific framework isn't among the listed, please create a new pull request and let us know.

MVVM Dialogs Contrib

The world is full of snowflakes and all applications are unique in some way. MVVM Dialogs takes no claim to solve all issues regarding dialogs, but is a fantastic solution for most applications. The rest, the applications deviating from the common path, may require specific changes to the behavior of MVVM Dialog. For those there is MVVM Dialogs Contrib. A repository with features and functionality developed by the open source community, solving very specific needs.

If MVVM Dialogs for some reason doesn't fit your application, raise an issue in MVVM Dialogs Contrib and we'll see what we can do. These features are always implemented by the community, but shepherded by the maintainers of MVVM Dialogs.

Install MVVM Dialogs via NuGet

If you want to include MVVM Dialogs in your project, you can install it directly from NuGet.

To install MVVM Dialogs, run the following command in the Package Manager Console:

PM> Install-Package MvvmDialogs

History

MVVM Dialogs started out as an article on CodeProject with its first revision published in May 2009. At that time MVVM was still new and fresh, and the now deprecated MVVM Light had yet not been published. In fact, none of the MVVM libraries commonly used today existed back then. MVVM Dialogs came about out of necessity to work with dialogs from the view model, a reaction to the fact that although MVVM was a popular pattern, the support to implement it was rather limited.

So, the initial publication was over 10 years ago. Give that a thought. An open source project that after 10 years still is maintained and extremely relevant with the releases of .NET. Take that all you out there claiming open source code is volatile!

Reputation

MVVM Dialogs has earned enough reputation to be listed on Awesome .NET!, in company with other awesome MVVM libraries.

Credit

Thank you JetBrains for your important initiative to support the open source community with free licenses to your products.

JetBrains

More Repositories

1

serilog-sinks-http

A Serilog sink sending log events over HTTP.
C#
169
star
2

aws-signature-version-4

The buttoned-up and boring, but deeply analyzed, implementation of SigV4 in .NET
C#
77
star
3

action-update-license-year

GitHub Action that in a pull request updates the copyright year(s) in your license file.
JavaScript
58
star
4

serilog-sinks-udp

A Serilog sink sending UDP packages over the network.
C#
30
star
5

serilog-sinks-http-sample-elastic-stack

Sample application of Serilog.Sinks.Http sending log events to Elastic Stack.
Shell
17
star
6

axis-js

A collection of Node.js packages written in TypeScript, helping you to interact with network cameras from Axis Communication.
TypeScript
15
star
7

searchlight

A cross-platform desktop application discovering Axis network video devices on your network
TypeScript
14
star
8

serilog-sinks-http-sample-dotnet-core

Sample application of Serilog.Sinks.Http producing log events in .NET Core.
C#
12
star
9

mvvm-dialogs-integrated-into-windows-community-toolkit

MVVM Dialogs integrated into CommunityToolkit.Mvvm
C#
11
star
10

axis-discovery-ssdp-js

A Node.js SSDP (UPnP) client library written in TypeScript capable of searching for Axis Communication cameras.
TypeScript
8
star
11

todo-cqrs

TodoMVC implementations using CQRS and event sourcing.
C#
7
star
12

expect

A Node.js library written in TypeScript providing argument validation.
TypeScript
5
star
13

axis-discovery-js

A Node.js client library written in TypeScript capable of searching for Axis Communication cameras using Bonjour and SSDP (UPnP).
TypeScript
5
star
14

mvvm-dialogs-integrated-into-caliburn-micro

MVVM Dialogs integrated into Caliburn.Micro
C#
4
star
15

mvvm-dialogs-integrated-into-mvvm-light-toolkit

MVVM Dialogs integrated into MVVM Light Toolkit
C#
3
star
16

mvvm-dialogs-contrib

Features and functionality complementing MVVM Dialogs
C#
3
star
17

teamcity-backup

A tool helping you to backup all your TeamCity projects and their settings.
C#
3
star
18

serilog-sinks-udp-sample-dotnet-core

Sample application of Serilog.Sinks.Udp producing log events in .NET Core.
C#
3
star
19

web-server-tech-benchmark

Project comparing the performance of web servers implemented in a small subset of programming languages.
C#
2
star
20

sandbox-hateoas

A HATEOAS playground suitable for a software developer.
C#
2
star
21

sandbox

A playground suitable for a software developer.
JavaScript
1
star
22

wpf-branding

C#
1
star
23

course-akka.net-bootcamp

A course in Akka.NET.
C#
1
star
24

renovate-config

Configuration file for Renovate (https://renovatebot.com/)
1
star
25

axis-configuration-js

A Node.js library written in TypeScript capable of configuring Axis Communication cameras.
TypeScript
1
star
26

namecheap-dynamic-dns-client

C#
1
star
27

certifications

Repository related to certifications
1
star
28

axis-discovery-bonjour-js

A Node.js Bonjour client library written in TypeScript capable of searching for Axis Communication cameras.
TypeScript
1
star
29

axis-maintenance-js

A Node.js library written in TypeScript capable of running maintenance operations on cameras from Axis Communication.
TypeScript
1
star
30

console-in-docker

A library helping .NET developers to build console applications in Docker.
PowerShell
1
star
31

FantasticFiasco

1
star
32

axis-snapshot-js

A Node.js library written in TypeScript capable of getting snapshots from Axis Communication cameras.
TypeScript
1
star
33

guid-generator

A replacement for the Visual Studio GUID Generator.
C#
1
star
34

serilog-sinks-http-sample-fluentd

Sample application of Serilog.Sinks.Http sending log events to Fluentd.
C#
1
star