Using regions without Application.Current set

Topics: Prism v4 - WPF 4
Nov 18, 2013 at 9:24 AM

I have discovered an issue when attempting to register regions while using PRISM without an Application.Current set. This occurs when launching a WPF window through COM from an unmanaged application and as far as I can tell there is no way to set the Application.Current without launching a whole new application.

The reason this not being set causes issues is because the check to determine whether you are in design mode checks the Application.Current is not null which was apparently done to compensate for a known issue in "Cider".

The following code snippet shows the area which i am referring to:
private static bool IsInDesignMode(DependencyObject element)
    // Due to a known issue in Cider, GetIsInDesignMode attached property value is not enough to know if it's in design mode.
    return DesignerProperties.GetIsInDesignMode(element) || Application.Current == null || Application.Current.GetType() == typeof(Application);
If you rely on GetIsInDesignMode only then Regions can register. Our current solution for this is to modify the library and rebuild it, however this is not ideal.

Can anyone think of a better solution to this that doesn't involve launching a whole new application, or modifying the PRISM libraries.
Nov 18, 2013 at 2:32 PM

This is a known bug in Prism since version 2, which has been reported in the following work items:

In them you can find different workarounds proposed by the community, including ones that do not require to modify the library.
Also, you can vote or post in the aforementioned work items (preferably in the one with the most votes) so that the team could take this problem into account for future releases.


Damian Cherubini