1

I've added WindowsMediaPlayer ActiveX to my WPF/MVVM application. Now I need the control to react to changes happening in the viewmodel (most importantly updating URL when the current selection in my collection changes). Based on Walkthrough: Hosting an ActiveX Control in WPF I have the following in my Loaded event:

// Create the interop host control.
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();

// Create the ActiveX control.
AxWMPLib.AxWindowsMediaPlayer axWmp = new AxWMPLib.AxWindowsMediaPlayer();

// Assign the ActiveX control as the host control's child.
host.Child = axWmp;

// Add the interop host control to the Grid
// control's collection of child controls.
this.pnlMediaPlayer.Children.Add(host);

Question is - how do I update the axWMP.URL control property on a property change in my viewmodel?

DaveO
  • 1,909
  • 4
  • 33
  • 63

1 Answers1

1

Ok, used Windows.Forms.Binding:

axWmp.DataBindings.Add(new System.Windows.Forms.Binding("URL",(DisplayViewModel)this.DataContext,"Source"));
DaveO
  • 1,909
  • 4
  • 33
  • 63
  • This worked great to update the ActiveX control from the ViewModel, but have you ever updated the View Model from the ActiveX control and if so how? – Zamboni Nov 12 '11 at 17:45