Regions are not created when element is in an ElementHost

Topics: Prism v2 - WPF 3.5
Jun 29, 2009 at 5:29 PM

We have a large existing application written in WinForms that we are slowly migrating to WPF.  We are trying to composite the application to include regions for modules to load views into.  Right now this requires us to slowly add regions to the application using the ElementHost interop WinForms control.

Everything about this seems to work fine, except when regions are automatically created.  This particular method seems to fall down:

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);
}

Because this is a WinForms hosted application, rather than a WPF application, the Application.Current property is null.  Modifying this line of code to exclude the Application.Current checks makes everything work swimmingly, however as you can imagine I'm a bit worried about the impact of this when we fully convert the shell to WPF.

Can anyone shed some light on this?  Is there a more accurate way to determine if the element is displayed in design mode?  Is the issue in WPF designer alluded to in this statement resolved?

Thanks!

 

 

Jun 29, 2009 at 6:54 PM

Nevermind... there is already an issue posted for this.

http://compositewpf.codeplex.com/WorkItem/View.aspx?WorkItemId=3552