WindowRegionAdapter : RegionAdapterBase Does not contain a constructor which takes 0 argument

Jun 17, 2009 at 1:11 PM

hello !

I using the new version of CAL (i.e. Prsim v2) and I could not find the RegionAdapterBase<T> class which takes 0 constructor ?

Since the WindowRegionAdapter inherits this class I getting an exception ... Is there any fix or a latest version released ?

Thanks !

//Kumar

Jun 17, 2009 at 1:24 PM

They added in a ctor parameter for the RegionAdapterBase class, so the adapters need a 1 argument ctor similar to this:

public class WindowRegionAdapter : RegionAdapterBase<ContentControl>
{
    public CustomRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
        : base(regionBehaviorFactory)
    {}
}

Jun 19, 2009 at 4:08 PM

I've updated the WindowReegionAdapter... but I am unclear on the change needed when registering the mappings.  This needs to now include the RegionBehaviorFactory

protected override RegionAdapterMappings ConfigureRegionAdapterMappings()

        {

            RegionAdapterMappings regionAdapterMappings = Container.TryResolve<RegionAdapterMappings>();

 

            if (regionAdapterMappings != null)

            {

              regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter() { WindowStyle = (Style)Application.Current.FindResource("WindowTemplate") })

            }

 

            return base.ConfigureRegionAdapterMappings();

        }

 

 

Thanks!

Tracy

Oct 28, 2009 at 4:51 PM

Hi Tracy,

I had a similar issue and am posting my fix for others.

I  fixed it with the following code, you need to use your IoC container to resolve an IRegionBehaviorFactory instance.

        protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
RegionAdapterMappings regionAdapterMappings = Container.TryResolve<RegionAdapterMappings>();
IRegionBehaviorFactory factory = Container.TryResolve<IRegionBehaviorFactory>();

if (regionAdapterMappings != null && factory != null)
{
regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter(factory) { WindowStyle = (Style)Application.Current.FindResource("WindowTemplate") });
}

return base.ConfigureRegionAdapterMappings();
}

Cheers,

Tony.