Click here to Skip to main content
15,879,184 members
Articles / Desktop Programming / WPF

MVVM PRISM: ProgressBar Interaction Request with Asynchronous Command

Rate me:
Please Sign up or sign in to vote.
4.81/5 (13 votes)
25 Sep 2011CPOL3 min read 48.6K   2.2K   45  
How to report progress of an asynchronous command by using a custom Interaction Request with a progress bar
//AUTHOR: GERARD CASTELLO
//DATE: 09/25/2011

using System;
using System.Windows.Controls;
using System.Windows;
using System.Collections;
using ProgressInteractionRequest.InteractionRequest.Views;

namespace ProgressInteractionRequest.InteractionRequest.Interactions
{
    public class InteractionDialogBase : UserControl
    {
        #region Events

        public event EventHandler Closed;

        #endregion

        #region Methods

        public void Close()
        {
            this.OnClose(EventArgs.Empty);
        }

        protected virtual void OnClose(EventArgs e)
        {
            var handler = this.Closed;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        public static UIElement FindDialog(Grid parent)
        {
            IEnumerator en = parent.Children.GetEnumerator();
            UIElement element = null;
            while (en.MoveNext() && element == null)
            {
                if (en.Current is IProgressbarView)
                    element = en.Current as UIElement;
            }
            return element;
        }

        #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)


Written By
Software Developer (Senior)
Spain Spain
http://www.linkedin.com/in/gerard-castello-viader
https://github.com/gcastellov

Comments and Discussions