Click here to Skip to main content
15,891,529 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.5K   5.6K   41  
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
using System;
using System.ComponentModel.Composition;
using System.Windows;
using MediaAssistant.Data;
using MediaAssistant.EventArguments;
using MefBasic;
using MefBasic.Commans;
using Microsoft.Practices.Composite.Events;

namespace MediaAssistant.Controls.PlayingMusicInfo
{
    [Export]
    public class PlayingMusicInfoPresenter:APresenter<IPlayingMusicInfoView>
    {
        [ImportingConstructor]
        public PlayingMusicInfoPresenter(IPlayingMusicInfoView view, IEventAggregator eventAggregator) : base(view)
        {
            eventAggregator.GetEvent<BaseEvent<PlayingMusicEventArgs>>().Subscribe(HandlePlayingMusicEvent);
        }

        private void HandlePlayingMusicEvent(PlayingMusicEventArgs obj)
        {
            if (obj.Music != null)
            {
                PlayingMusicTitle = string.IsNullOrWhiteSpace(obj.Music.Title) ? obj.Music.FileName : obj.Music.Title;
                PlayingMusicArtist = obj.Music.Artist;
                TimelineVisibility = Visibility.Visible;
            }
            else
            {
                PlayingMusicTitle = string.Empty;
                PlayingMusicArtist = string.Empty;
                TimelineVisibility = Visibility.Hidden;
            }
        }

        [Import]
        public LibraryDataSource DataSource
        {
            get { return (LibraryDataSource)GetValue(DataSourceProperty); }
            set { SetValue(DataSourceProperty, value); }
        }

        public static readonly DependencyProperty DataSourceProperty =
            DependencyProperty.Register("DataSource", typeof(LibraryDataSource), typeof(PlayingMusicInfoPresenter), new UIPropertyMetadata(null));




        public Visibility TimelineVisibility
        {
            get { return (Visibility)GetValue(TimelineVisibilityProperty); }
            set { SetValue(TimelineVisibilityProperty, value); }
        }

        public static readonly DependencyProperty TimelineVisibilityProperty =
            DependencyProperty.Register("TimelineVisibility", typeof(Visibility), typeof(PlayingMusicInfoPresenter), new UIPropertyMetadata(Visibility.Hidden));

        
        public string PlayingMusicArtist
        {
            get { return (string)GetValue(PlayingMusicArtistProperty); }
            set { SetValue(PlayingMusicArtistProperty, value); }
        }

        public static readonly DependencyProperty PlayingMusicArtistProperty =
            DependencyProperty.Register("PlayingMusicArtist", typeof(string), typeof(PlayingMusicInfoPresenter), new UIPropertyMetadata(null));



        public string PlayingMusicTitle
        {
            get { return (string)GetValue(PlayingMusicTitleProperty); }
            set { SetValue(PlayingMusicTitleProperty, value); }
        }

        public static readonly DependencyProperty PlayingMusicTitleProperty =
            DependencyProperty.Register("PlayingMusicTitle", typeof(string), typeof(PlayingMusicInfoPresenter), 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