Search code examples
wpfmvvmactivexwindowsformshost

ActiveX Control In WPF Windows Form Host Not Displaying After Becoming Visible


I have a wpf usercontrol that contains an activex control housed in a windowsformhost. I'm using an MVVM pattern that says ViewModel1 is mapped to a Pure WPF View and ViewModel2 is mapped to wpf content and the above usercontrol

If ViewModel2 is "Hidden" and then becomes Visible then the Activex control inside it doesn't show (Specifically I'm talking about the VLC activex control).

I've tested in a non MVVM pattern with a button and the usercontrol. The usercontrol is hidden until you press the button and the same thing happens but if I create a method in the usercontrol to re attach the activex control to the windowsformhost then it reappears. If I call this method from a viewmodel then it still remains blank. Does anyone know how I can get this to show again?

EDIT - I've just discovered it's because I have transparency on in my wpf application. It seems it's not possable to do what I want with windowsformshost and transparency enabled.


Solution

  • As there are no obvious answers I'll share my experience. When transparency is turned on in the wpf window then the windows form host doesn't refresh when changing from Hidden to Visable. I have found no way to make this work unless it is hosted in a new window with "Allowstransparency=false".