Hello,
how can i save the ribbon customizations to a stream from code, without using the customization window?
Thank you in advance,
Michael
Hi,
The ribbon exposes two methods that you can use: ribbon.ExportRibbonLayout() and respectively - ImportRibbonLayout(), both accepting a stream as an input parameter.
Hope this helps,
Hi Georgi,
i have already tried these methods and they throw an exception, below is the stack trace on Export
"System.NullReferenceException was unhandled by user code Message=Object reference not set to an instance of an object. StackTrace: at Infragistics.Controls.Menus.RibbonCustomizationControl.CreateGroupXml(RibbonGroupDataModel group) at Infragistics.Controls.Menus.RibbonCustomizationControl.CreateTabXml(RibbonTabDataModel tab) at Infragistics.Controls.Menus.RibbonCustomizationControl.CreateTabGroupXml(RibbonTabGroupDataModel tabGroup) at Infragistics.Controls.Menus.RibbonCustomizationControl.ExportRequested() at Infragistics.Controls.Menus.XamRibbon.ExportRibbonLayout(Stream ribbonData) at XXXXXXX.Views.ShellView.GetSettings() at XXXXXX.ViewModels.MainViewModel.GetSettings() at XXXXXX.Services.PersistenceService.Remember(String key, IPersistSettings item) at XXXXXXXX.PersistenceService.Remember(IPersistSettings item) at XXXXXXXXX.ViewModels.MainViewModel.<.ctor>b__3(BeforeSave msg) at GalaSoft.MvvmLight.Helpers.WeakAction`1.Execute(T parameter) at GalaSoft.MvvmLight.Helpers.WeakAction`1.ExecuteWithObject(Object parameter) at GalaSoft.MvvmLight.Messaging.Messenger.SendToList[TMessage](TMessage message, IEnumerable`1 weakActionsAndTokens, Type messageTargetType, Object token) at GalaSoft.MvvmLight.Messaging.Messenger.SendToTargetOrType[TMessage](TMessage message, Type messageTargetType, Object token) at GalaSoft.MvvmLight.Messaging.Messenger.Send[TMessage](TMessage message) at XXXXX.UI.Services.PersistenceService.GetSettings() at XXXXXX.XXXXXXXXX.ViewModels.WorkspacesViewModel.b__2() at GalaSoft.MvvmLight.Helpers.WeakAction.Execute() at GalaSoft.MvvmLight.Command.RelayCommand.Execute(Object parameter) at System.Windows.Controls.Primitives.ButtonBase.ExecuteCommand() at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.HyperlinkButton.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)"
I thought that the method is to be called only from the customization form and i misused them...
But there must be a bug, because the null reference exception is raised from customization form also, you can check it on the Matt's example which i upgraded to v12.2 latest SP
Hi Michael,
Yes - this definitely looks like a bug. I'll make sure it gets DEV's attention. Thanks for reporting it!
HI,
This issue has been resolved with the latest service release.
Sincerely,
Matt Developer Support Engineer