Click here to Skip to main content
15,884,939 members
Articles / Desktop Programming / WPF

Building WPF Applications with Self-Tracking Entity Generator - Project Setup

Rate me:
Please Sign up or sign in to vote.
4.80/5 (11 votes)
20 Feb 2012CPOL10 min read 75.3K   4.8K   54  
This article describes the project setup of building a WPF sample application with Self-Tracking Entity Generator for WPF/Silverlight.
using System;
using GalaSoft.MvvmLight.Messaging;

namespace SchoolSample.Common
{
    public class AppMessages
    {
        enum MessageTypes
        {
            RaiseError,
            PleaseConfirm,
            StatusUpdate,
            BeginEdit,
            CancelEdit,
            EndEdit
        }

        public static class RaiseErrorMessage
        {
            public static void Send(Exception ex)
            {
                Messenger.Default.Send(ex, MessageTypes.RaiseError);
            }

            public static void Register(object recipient, Action<Exception> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.RaiseError, action);
            }
        }

        public static class PleaseConfirmMessage
        {
            public static void Send(DialogMessage dialogMessage)
            {
                Messenger.Default.Send(dialogMessage, MessageTypes.PleaseConfirm);
            }

            public static void Register(object recipient, Action<DialogMessage> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.PleaseConfirm, action);
            }
        }

        public static class StatusUpdateMessage
        {
            public static void Send(DialogMessage dialogMessage)
            {
                Messenger.Default.Send(dialogMessage, MessageTypes.StatusUpdate);
            }

            public static void Register(object recipient, Action<DialogMessage> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.StatusUpdate, action);
            }
        }

        public static class BeginEditMessage
        {
            public static void Send(string screenName)
            {
                Messenger.Default.Send(screenName, MessageTypes.BeginEdit);
            }

            public static void Register(object recipient, Action<string> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.BeginEdit, action);
            }
        }

        public static class CancelEditMessage
        {
            public static void Send(string screenName)
            {
                Messenger.Default.Send(screenName, MessageTypes.CancelEdit);
            }

            public static void Register(object recipient, Action<string> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.CancelEdit, action);
            }
        }

        public static class EndEditMessage
        {
            public static void Send(string screenName)
            {
                Messenger.Default.Send(screenName, MessageTypes.EndEdit);
            }

            public static void Register(object recipient, Action<string> action)
            {
                Messenger.Default.Register(recipient, MessageTypes.EndEdit, action);
            }
        }
    }
}

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)
United States United States
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET

Comments and Discussions