wpfwinformsprism-4

Prism4 view based navigation doesn't work in WinForms ElementHost


I have a WPF application which uses the Prism4 Unity libraries. Now I have to show this WPF application in a Win Forms Window. To do so I put all the code from the WPF-"MainWindow" into a single user control to get a "MainControl" which i can still display in a WPF window but also in a "ElementHost"-control in Win Forms.

At the beginning the "MainControl" is shown correctly in the Win Forms window but when i try to navigate, the views in the regions don't switch. In a WPF window everything works still perfect.

I call the navigation like this:

_RegionManager.RequestNavigate("MainRegion", "ControlOne");

The functions "OnNavigatedTo", "OnNavigatedFrom", "IsNavigationTarget" form the "INavigationAware" Interface also get called. When i take a look at the region in debug mode, "ControlOne" is set and activated but it doesn't get shown on the UI.

First i thought it is a refresh-problem, but if the view is register with the region like this, "ControlOne" is shown. but I'm not able to put another view into the region the same way.

_RegionManager.RegisterViewWithRegion("MainRegion", () => m_UnityContainer.Resolve<ControlOne>());

Solution

  • Found a solution. RegionManager was the problem.

    This post helped. http://www.telerik.com/forums/prism-regionmanager-cannot-navigate-when-radpane-is-not-docked