1
votes

I am looking for a strategy to implement a new WPF 4.0 application with the MVVM pattern that reuses various VB6 user controls. I'd like to have both WPF and VB6 controls share the same view model.

Are there any known strategies for this?

1
You know that VB6 is unsupported as of 2008, right?John Saunders
@John: I think VB6 is less important to the question than COM.Gregory A Beamer
@GregoryABeamer: Possibly, but making sure the OP knows - surprisingly, not everyone is aware that it's unsupported.:John Saunders
@John: What? Next you will tell me Windows 3.1 is not a supported operating system. ;-)Gregory A Beamer
I cannot afford to rewrite the entire application in one release cycle and I need to spread the work over a few years.Zamboni

1 Answers

3
votes

You can host an ActiveX control in WPF, as this walkthrough shows. That is your first issue. Assuming the VB6 bits are set up as an ActiveX control, you have most of the game conquered.

Using the same view model (UI data?) in the control should not be a major undertaking, depending on how the control is written. You have to be able to direct the view model to the control, which means there is some exposed method or property.

So, I see two potential obstacles:

  1. Control is not ActiveX
  2. Control exposes no obvious means to transfering view model from WPF code into the control for display

Unless you are absolutely forced to use the VB6 control, however, I would consider using a more modern UI element.