Hi,
I'd like to save 'shortcuts' added by users in the Quick Access Toolbar between sessions, in order to reload it on startup.
I found many examples for Windows forms, but mentioned methods (Ribbon.savesettingstostream, ribbon.savetoXML) seems not to be implemented in WPF.
Does anybody know how to do?
thanks
Hello Krasimir,
I tried the mechanism from your sample in my application, where the ribbon is filled at runtime.
In the first try, I got exceptions like these all the time:
UnhandledException: System.InvalidOperationException: An item with the specified TargetId 'XYZMYITEMKEY' being added to the QuickAccessToolbar is not registered with the associated XamRibbon. at Infragistics.Windows.Ribbon.QatPlaceholderTool.VerifyAssociatedTool() in e:\Work\2\242\Sources\RELEASE\XAML\2011.1\Source\Ribbon\Tools\QatPlaceholderTool.cs:line 508 at Infragistics.Windows.Ribbon.QatPlaceholderTool.VerifyAssociatedTarget() in e:\Work\2\242\Sources\RELEASE\XAML\2011.1\Source\Ribbon\Tools\QatPlaceholderTool.cs:line 477 at Infragistics.Windows.Ribbon.QatPlaceholderTool.OnLoaded(Object sender, RoutedEventArgs e) in e:\Work\2\242\Sources\RELEASE\XAML\2011.1\Source\Ribbon\Tools\QatPlaceholderTool.cs:line 390 at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent) at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root) at MS.Internal.LoadedOrUnloadedOperation.DoWork() at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
That may be caused by I first put the ButtonTools into the RibbonGroups, the groups into the Tabs and then added the filled tabs into the ribbon.
It has improved after I changed this to:First add tabs, then add groups to tabs, then add items (ToolButtons) to groups.
Now, RibbonGroups and ButtonTools from within the RibbonGroups can properly be added to the QAT and I can save/restore their keys and types.
But still, some items cause the exception above when trying to restore the QAT-Items, as if they were not correctly registered with the ribbon. But I know they are present in the ribbon (just not in the first tab, maybe that's the point?),
Is there any way to make sure that each key is correctly registered with the ribbon?
Everything is ok. Thanks
Hello Lionel,
If the Id property of a tool is not set initially it is set to “(ID)” followed by a random generated number. Every time when you start your application the ids of the tools will be different and it will throw the exception that you are getting.
The idea of my sample application was to set initially the ids of the tools. If you set the ids initially in the XAML code you can prevent this exception of being thrown.
Please let me know if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
Finally, i solved my problem by deleting "(ID)" characters in Id. It seems to fix it and, then, it works.
Is it the good way to proceed?
Hello,
Sorry for answering so late. Due to troubles with my email server, i didn't received any email notification for your previous answer.
It doesn't work fine for me, an error occurs when reloading : "An item with the specified TargetId '(ID)634359570788694218703564304' being added to the QuickAccessToolbar is not registered with the associated XamRibbon"
Indeed, this Id is different tan the one I can see in Visual Studio. Moreover, the Id is also different when I open the project on another computer. However, the one read is the one written previously. The problem seems to be that runtime Ids are different than designtime Ids. Is there any way to "freeze" it?
Sincerely