Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / WPF

Wrap Panel Virtualization

Rate me:
Please Sign up or sign in to vote.
4.95/5 (18 votes)
2 Jan 2012CPOL2 min read 53.4K   5.6K   41  
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
using System.Windows;
using System.Diagnostics;

namespace MediaAssistant.Controls.SplashScreen
{
    public class MessageListener : DependencyObject
    {
        private static MessageListener mInstance;

        private MessageListener ( )
        {

        }

        public static MessageListener Instance
        {
            get
            {
                if ( mInstance == null )
                    mInstance = new MessageListener ( );
                return mInstance;
            }
        }

        public void ReceiveMessage ( string message )
        {
            Message = message;
            Debug.WriteLine ( Message );
            DispatcherHelper.DoEvents ( );
        }
       
        public string Message
        {
            get
            {
                return ( string ) GetValue ( MessageProperty );
            }
            set
            {
                SetValue ( MessageProperty, value );
            }
        }
        
        public Visibility BusyIconVisibility
        {
            get
            {
                return (Visibility)GetValue(BusyIconVisibilityProperty);
            }
            set
            {
                SetValue(BusyIconVisibilityProperty, value);
                DispatcherHelper.DoEvents();
            }
        }

        public static readonly DependencyProperty BusyIconVisibilityProperty =
            DependencyProperty.Register("BusyIconVisibility", typeof(Visibility), typeof(MessageListener), new UIPropertyMetadata(Visibility.Hidden));


        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register ( "Message", typeof ( string ), typeof ( MessageListener ), new UIPropertyMetadata ( null ) );

    }
}

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) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions