Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Presentation Model (MVVM) Good Practices

, 11 May 2010 CPOL
Showing some good practices that can be applied to the Presentation Model/MVVM pattern.
PresentationModelDemo.zip
App.Configuration
App.Configuration.Wpf
Interceptors
Properties
Wpf
Properties
Wpf
App.Core
Model
PresentationModel
Properties
Services
App.Data
Properties
libs
AttachedCommandBehavior.dll
Castle.Core.dll
Castle.DynamicProxy2.dll
Castle.MicroKernel.dll
Castle.Windsor.dll
PresentationModelBase
Properties
WPFUI
Properties
Settings.settings
View
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PresentationModelBase;
using Microsoft.Win32;

namespace App.Configuration
{
    class WpfDialogSystem : IDialogSystem
    {
        #region IDialogServicesProvider Members

        public MessageBoxResult AskQuestion(string question)
        {
            return AskQuestion(question, "Question");
        }

        public MessageBoxResult AskQuestion(string question, string title)
        {
            var result = System.Windows.MessageBox.Show(question, title, System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
            switch (result)
            {
                case System.Windows.MessageBoxResult.Yes:
                    return MessageBoxResult.Yes;
                default:
                    return MessageBoxResult.No;
            }
        }

        public System.IO.FileInfo ChooseFile(string title, string filter)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = title;
            dialog.Filter = filter;
            dialog.ShowDialog();
            if (dialog.FileName != null && dialog.FileName.Trim() != string.Empty)
                return new System.IO.FileInfo(dialog.FileName);
            return null;
        }

        public System.IO.FileInfo ChooseImage()
        {
            return ChooseImage("");
        }

        public System.IO.FileInfo ChooseImage(string title)
        {
            return ChooseFile(title, "Image Files (*.bmp, *.jpg, *.jpeg, *.png)|*.bmp;*.jpg;*.jpeg;*.png");
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Software developer specialized in the .NET framework

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 11 May 2010
Article Copyright 2010 by Thiago de Arruda
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid