How to implement two way binding between an ActiveX control and a WPF MVVM View Model

Posted by Zamboni on Stack Overflow See other posts from Stack Overflow or by Zamboni
Published on 2011-11-12T17:38:31Z Indexed on 2011/11/12 17:51 UTC
Read the original article Hit count: 405

Filed under:
|
|
|
|

I have a WPF application implemented using the MVVM framework that uses an ActiveX control and I need to keep the WPF and ActiveX UI synchronised.

So far I can update the ActiveX UI when I change the WPF UI using the code at the bottom of the question that I got from the article Hosting an ActiveX Control in WPF and this question.

But I cannot update the WPF UI when I make a change in the ActiveX UI.

I suspect that I need to fire the PropertyChanged event from my ActiveX control but I have no idea how to do this or if it is even possible.

The ActiveX controls I have written are in VB6 and MFC as I am just prototying at this time for the eventual integration of VB6 ActiveX controls in a WPF contaner application.

Here is a code snipet that indicates the work done so far:

System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

// Create the ActiveX control.
AxTEXTBOXActiveXLib.AxTEXTBOXActiveX axWmp = new AxTEXTBOXActiveXLib.AxTEXTBOXActiveX();

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

axWmp.DataBindings.Add(new System.Windows.Forms.Binding("ActiveXStatus", (MainWindowViewModel)this.DataContext, "ModelStatus", true, DataSourceUpdateMode.OnPropertyChanged ));

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

How to implement two way binding between an ActiveX control and a WPF MVVM View Model?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mvvm