NCAL and the Ribbon Control

Jun 23, 2009 at 1:58 PM

I have been exploring the use of the xamRibbon control within NCAL. Has anyone anyone worked in creating an Adapter for the xamRibbon? Instead of using the IRegion approach I felt that perhaps it would be better to find a way to explose an instance of the main Ribbon control. I feel that the Ribbon is more of a specialized Toolbar than a region manager. Any thoughts?

Jul 22, 2009 at 10:05 AM

You can try it with something like this:

 

public class RibbonControlRegionAdapter : RegionAdapterBase<XamRibbon>
    {
        private XamRibbon _regionTarget;  

        
        protected override IRegion CreateRegion()
        {
            return new AllActiveRegion();  
        }

        protected override void Adapt(IRegion region, XamRibbon  regionTarget)
        {
            _regionTarget = regionTarget;
            regionTarget.Tabs.Clear();
            region.ActiveViews.CollectionChanged +=
                OnActiveViewsChanged;  
             foreach ( RibbonTabItem v in region.ActiveViews)  
             regionTarget.Tabs.Add(v);

        }

         private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e)  
     {  
         switch (e.Action)  
         {  
             case NotifyCollectionChangedAction.Add:  
                 foreach (RibbonTabItem v in e.NewItems)  
                     _regionTarget.Tabs.Add(v);  
                 break;  
   
             case NotifyCollectionChangedAction.Remove:  
                 foreach (RibbonTabItem v in e.NewItems)  
                     _regionTarget.Tabs.Remove(v);  
                 break;  
   
         }  
     }

 

Im stillt testing the Infrangristic Trial and don`t know if i`ll realy wan`t to use it in my Products, so i did not spent the time to write a Proxy for the Ribbon Control. But if you use it in Production i recomand to write a Proxy for the Ribbon as well, and do not use the Control directly.

May 26, 2010 at 12:15 AM

Hello,

     Do you get the solution for the question , Can you send me an example code for that? Thank you very much.

yours,