开发者

How to hook ActiveX control into events/changes into my viewmodel?

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 contro开发者_JAVA技巧l property on a property change in my viewmodel?


Ok, used Windows.Forms.Binding:

axWmp.DataBindings.Add(new System.Windows.Forms.Binding("URL",(DisplayViewModel)this.DataContext,"Source"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜