Click here to Skip to main content
15,896,359 members
Articles / Desktop Programming / WPF

Using the Microsoft Desktop Stack – Part 3: Using Entity Framework 4 in an MVVM Application

Rate me:
Please Sign up or sign in to vote.
4.73/5 (21 votes)
17 Apr 2011CPOL25 min read 73.8K   4.9K   56  
This article, shows how to integrate Entity Framework 4 into a WPF application using the MVVM pattern.
using System.Windows;
using MsDesktopStackDemo.Events;

namespace MsDesktopStackDemo.View.Services
{
    public class ViewServices
    {
        /// <summary>
        /// Displays a message from the app to the user.
        /// </summary>
        /// <param name="category">The category of the message (e.g., warning, notification).</param>
        /// <param name="caption">The message box caption.</param>
        /// <param name="message">The message box text.</param>
        public static void ShowUserMessage(UserMessageCategories category, string caption, string message)
        {
            // Set icon
            var icon = MessageBoxImage.None;
            switch (category)
            {
                case UserMessageCategories.Error:
                    icon = MessageBoxImage.Error;
                    break;

                case UserMessageCategories.Warning:
                    icon = MessageBoxImage.Warning;
                    break;

                case UserMessageCategories.Information:
                    icon = MessageBoxImage.Information;
                    break;
            }

            // Show message box
            MessageBox.Show(message, caption, MessageBoxButton.OK, icon);
        }
    }
}

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)


Written By
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

Comments and Discussions