GithubHelp home page GithubHelp logo

smartencounter / mvvm-dialogs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fantasticfiasco/mvvm-dialogs

0.0 2.0 0.0 3.28 MB

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

License: Apache License 2.0

Batchfile 0.37% HTML 25.27% C# 71.59% Smalltalk 2.77%

mvvm-dialogs's Introduction

MVVM Dialogs

MVVM Dialogs logo

Introduction

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

The framework has built in support for opening 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);
    }
  }
}

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.