MVVM pattern violation: MediaElement.Play()

1) Do not call Play() from the view model. Raise an event in the view model instead (for instance PlayRequested) and listen to this event in the view: view model: public event EventHandler PlayRequested; … if (this.PlayRequested != null) { this.PlayRequested(this, EventArgs.Empty); } view: ViewModel vm = new ViewModel(); this.DataContext = vm; vm.PlayRequested += (sender, … Read more

Using MediaElement to play video from Stream

Before anyone wastes hours finding this out for themselves: it is impossible to host the Silverlight MediaElement in a WPF application. The reason for this is that it is one of a number of types that appear in PresentationFramework.dll (unavoidable for WPF) and System.Windows.dll (Silverlight versions) that have the same names and the same namespaces, … Read more