Writing a region adapter for the ribbon control

Topics: Prism v2 - WPF 3.5
May 20, 2009 at 3:00 PM

I'm trying to write a region adapter for the ribbon control and I'm stuck at the first hurdle.

Here's the stub for my class....

using Microsoft.Practices.Composite.Presentation.Regions;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Windows.Controls.Ribbon;

namespace My.Composite.Presentation.Regions
{
    public class RibbonRegionAdapter : RegionAdapterBase<Ribbon>
    {
        protected override void Adapt(IRegion region, Ribbon regionTarget)
        {
            throw new System.NotImplementedException();
        }

        protected override IRegion CreateRegion()
        {
            throw new System.NotImplementedException();
        }
    }
}

and here's the error I get when trying to compile it....

'Microsoft.Practices.Composite.Presentation.Regions.RegionAdapterBase<Microsoft.Windows.Controls.Ribbon.Ribbon>' does not contain a constructor that takes '0' arguments

I think this means the ribbon class does not have a constructor that takes 0 args?

When I look at the ribbon class the only constructor it has does infact take 0 args but having said that, the class is annotated with the following...

[ContentProperty("Tabs")]

Is this the problem?

How do I fix it?

 

In case anyone has any advice what I'm trying to do here is create a region adapter for the ribbon control such that a module could inject a view onto the ribbon.

That view would take the form of a RibbonTab. For now I'd be more than happy if each of my modules could have a tab on the ribbon.

 

Many thanks,

 

MQCA.

 

May 20, 2009 at 3:05 PM

Scratch that, I figured it out just after posting (always the way).

The error did infact relate to my ribbonregionadapter class.

I stole this bit of code from a different region adapter and it fixed the issue.

        public RibbonRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
            : base(regionBehaviorFactory)
        {
        }