Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Dynamically Loading Silverlight Video Players using MEF

, , 24 Aug 2010
An example using MEF to dynamically load Silverlight Video Players
Base.zip
SkinableVideoPlayer
SkinableVideoPlayer.Web
App_Code
ClientBin
SkinableVideoPlayer.xap
Video
desktop.ini
niceday.wmv
Thumbs.db
Webservice
SkinableVideoPlayerViewModel
Bin
Debug
ar
bg
ca
cs
da
de
el
es
et
eu
fi
fr
he
hr
hu
id
it
ja
ko
lt
lv
ms
nl
no
pl
pt
pt-BR
ro
ru
sk
SkinableVideoPlayerViewModel.dll
sl
sr-Cyrl-CS
sr-Latn-CS
sv
th
tr
uk
vi
zh-Hans
zh-Hant
Release
classes
Model
Properties
Service References
wsSkinableVideoPlayer
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayerViewModel.csproj.user
ViewModel
Bin
Debug
ar
System.Windows.Controls.resources.dll
bg
System.Windows.Controls.resources.dll
ca
System.Windows.Controls.resources.dll
cs
System.Windows.Controls.resources.dll
da
System.Windows.Controls.resources.dll
de
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
el
System.Windows.Controls.resources.dll
es
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
et
System.Windows.Controls.resources.dll
eu
System.Windows.Controls.resources.dll
fi
System.Windows.Controls.resources.dll
fr
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
he
System.Windows.Controls.resources.dll
hr
System.Windows.Controls.resources.dll
hu
System.Windows.Controls.resources.dll
id
System.Windows.Controls.resources.dll
it
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
ja
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
ko
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
lt
System.Windows.Controls.resources.dll
lv
System.Windows.Controls.resources.dll
Microsoft.Expression.Interactions.dll
ms
System.Windows.Controls.resources.dll
nl
System.Windows.Controls.resources.dll
no
System.Windows.Controls.resources.dll
pl
System.Windows.Controls.resources.dll
pt
pt-BR
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
ro
System.Windows.Controls.resources.dll
ru
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
sk
SkinableVideoPlayer.dll
SkinableVideoPlayer.xap
SkinableVideoPlayerViewModel.dll
System.Windows.Controls.resources.dll
sl
System.Windows.Controls.resources.dll
sr-Cyrl-CS
System.Windows.Controls.resources.dll
sr-Latn-CS
System.Windows.Controls.resources.dll
sv
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.dll
System.ComponentModel.Composition.Initialization.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
th
System.Windows.Controls.resources.dll
tr
System.Windows.Controls.resources.dll
uk
System.Windows.Controls.resources.dll
vi
System.Windows.Controls.resources.dll
zh-Hans
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
zh-Hant
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
Release
classes
Models
Properties
Service References
wsSkinableVideoPlayer
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayer.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayer.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayer.csproj.user
ViewModels
Views
CompleteProjectWithAllSampleVideoPlayers.zip
PhilMiddlemissTheme
Bin
Debug
ar
bg
ca
cs
da
de
el
es
et
eu
fi
fr
he
hr
hu
id
it
ja
ko
lt
lv
ms
nl
no
PhilMiddlemissTheme.dll
PhilMiddlemissTheme.xap
pl
pt
pt-BR
ro
ru
sk
sl
sr-Cyrl-CS
sr-Latn-CS
sv
th
tr
uk
vi
zh-Hans
zh-Hant
Release
PhilMiddlemissTheme.csproj.user
Properties
Resources
Views
Hiro.xap
PhilMiddlemissTheme.xap
SkinableVideoPlayer.xap
SkinableVideoPlayer_View.xap
desktop.ini
niceday.wmv
Thumbs.db
SkinableVideoPlayerViewModel.dll
ClassDiagram1.cd
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayerViewModel.csproj.user
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
Microsoft.Expression.Interactions.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
SkinableVideoPlayer.dll
SkinableVideoPlayer.xap
SkinableVideoPlayerViewModel.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.dll
System.ComponentModel.Composition.Initialization.dll
System.CoreEx.dll
System.Observable.dll
System.Reactive.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayer.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayer.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayer.csproj.user
SkinableVideoPlayer_View
Bin
Debug
ar
bg
ca
cs
da
de
el
es
et
eu
fi
fr
he
hr
hu
id
it
ja
ko
lt
lv
ms
nl
no
pl
pt
pt-BR
ro
ru
sk
SkinableVideoPlayer_View.dll
SkinableVideoPlayer_View.xap
sl
sr-Cyrl-CS
sr-Latn-CS
sv
th
tr
uk
vi
zh-Hans
zh-Hant
Release
Properties
SampleData
ServiceReferences.ClientConfig
SkinableVideoPlayer_View.csproj.user
Views
VersionOne.zip
SkinableVideoPlayer.xap
VersionOne.xap
desktop.ini
niceday.wmv
Thumbs.db
SkinableVideoPlayerViewModel.dll
SkinableVideoPlayerViewModel.pdb
obj
Debug
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
SampleData
SkinableVideoPlayerViewModel.dll
SkinableVideoPlayerViewModel.pdb
TempPE
Service References.wsSkinableVideoPlayer.Reference.cs.dll
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayerViewModel.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayerViewModel.csproj.user
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
Microsoft.Expression.Interactions.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
SkinableVideoPlayer.dll
SkinableVideoPlayer.xap
SkinableVideoPlayerViewModel.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.dll
System.ComponentModel.Composition.Initialization.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Interactivity.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.Initialization.resources.dll
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
SkinableVideoPlayer.wsSkinableVideoPlayer.GetVideosResponse.datasource
SkinableVideoPlayer.wsSkinableVideoPlayer.GetXapsResponse.datasource
WebService.disco
WebService.wsdl
ServiceReferences.ClientConfig
SkinableVideoPlayer.csproj.user
VersionOne
Bin
Debug
ar
System.Windows.Controls.resources.dll
bg
System.Windows.Controls.resources.dll
ca
System.Windows.Controls.resources.dll
cs
System.Windows.Controls.resources.dll
da
System.Windows.Controls.resources.dll
de
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
el
System.Windows.Controls.resources.dll
es
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
et
System.Windows.Controls.resources.dll
eu
System.Windows.Controls.resources.dll
fi
System.Windows.Controls.resources.dll
fr
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
he
System.Windows.Controls.resources.dll
hr
System.Windows.Controls.resources.dll
hu
System.Windows.Controls.resources.dll
id
System.Windows.Controls.resources.dll
it
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
ja
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
ko
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
lt
System.Windows.Controls.resources.dll
lv
System.Windows.Controls.resources.dll
ms
System.Windows.Controls.resources.dll
nl
System.Windows.Controls.resources.dll
no
System.Windows.Controls.resources.dll
pl
System.Windows.Controls.resources.dll
pt
pt-BR
System.Windows.Controls.resources.dll
System.Windows.Controls.resources.dll
ro
System.Windows.Controls.resources.dll
ru
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
sk
System.Windows.Controls.resources.dll
sl
System.Windows.Controls.resources.dll
sr-Cyrl-CS
System.Windows.Controls.resources.dll
sr-Latn-CS
System.Windows.Controls.resources.dll
sv
System.Windows.Controls.resources.dll
System.ComponentModel.Composition.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Controls.Toolkit.pdb
System.Windows.Interactivity.dll
th
System.Windows.Controls.resources.dll
tr
System.Windows.Controls.resources.dll
uk
System.Windows.Controls.resources.dll
VersionOne.dll
VersionOne.pdb
VersionOne.xap
vi
System.Windows.Controls.resources.dll
zh-Hans
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
zh-Hant
System.ComponentModel.Composition.resources.dll
System.Windows.Controls.resources.dll
Release
obj
Debug
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
TempPE
VersionOne.dll
VersionOne.g.resources
VersionOne.pdb
Views
Properties
VersionOne.csproj.user
Views
using System.Windows.Input;
using System;

// From http://johnpapa.net/silverlight/5-simple-steps-to-commanding-in-silverlight/
public class DelegateCommand : ICommand
{
    Func< object, bool > canExecute;
    Action< object > executeAction;
    bool canExecuteCache;

    public DelegateCommand(Action<object> executeAction, Func<object, bool> canExecute)
    {
        this.executeAction = executeAction;
        this.canExecute = canExecute;
    }

    #region ICommand Members

    public bool CanExecute(object parameter)
    {
        bool temp = canExecute(parameter);

        if (canExecuteCache != temp)
        {
            canExecuteCache = temp;
            if (CanExecuteChanged != null)
            {
                CanExecuteChanged(this, new EventArgs());
            }
        }

        return canExecuteCache;
    }

    public event EventHandler CanExecuteChanged;

    public void Execute(object parameter)
    {
        executeAction(parameter);
    }

    #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 Microsoft Public License (Ms-PL)

Share

About the Authors

defwebserver
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
LightSwitchHelpWebsite.com

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:
Follow on   Twitter

hisowa
Software Developer
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 25 Aug 2010
Article Copyright 2010 by defwebserver, hisowa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid