I am trying to persist QAT items. I've been running into two issues (so far):
1. When using the following markup:
<r:XamRibbon.QuickAccessToolbar> <r:QuickAccessToolbar> <r:QuickAccessToolbar.ItemTemplate> <DataTemplate> <r:QatPlaceholderTool TargetId="{Binding}" /> </DataTemplate> </r:QuickAccessToolbar.ItemTemplate> </r:QuickAccessToolbar> </r:XamRibbon.QuickAccessToolbar>
and code:
ribbon.QuickAccessToolbar.ItemsSource = settings.QuickAccessItems;
I'm getting UnsupportedOperationException with the message:
Item of type 'System.String' cannot be added directly to the QuickAccessToolbar. [...]
2. When attempting to restore a group, I'm getting UnsupportedOperationException with the message:
An item with the specified TargetId 'GroupId' being added to the QuickAccessToolbar is not registered with the associated XamRibbon.
Is it me or is it XamRibbon? Is QAT persistence a planned feature? If it is, when will it be available?
I was able to work around the first issue as well by using:
<r:XamRibbon.QuickAccessToolbar> <r:QuickAccessToolbar ItemsSource="{Binding QuickAccessToolbarItems}" /> </r:XamRibbon.QuickAccessToolbar>
and creating the QuickAccessToolbarItems as ObservableCollection<FrameworkElement> (since in addition to QatPlaceholderTools it may contain SeparatorTools).
Instead of using QuickAccessToolbarItems as ObservableCollection<FrameworkElement>
Can we use some ObservableCollection<XXX> where XXX is my class.. (object)
<Style TargetType="{x:Type igRibbon:QuickAccessToolbar}"> <Setter Property="ItemTemplate" Value="{StaticResource Local_DefaultQuickAccessToolbarTemplate}" /> <Setter Property="ItemsSource" Value="{Binding Items}"/> <Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" /> </Style>
<DataTemplate x:Key="Local_DefaultQuickAccessToolbarTemplate" > <!--<igRibbon:ToolHorizontalWrapPanel>--> <igRibbon:QatPlaceholderTool igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge" TargetId="{Binding Name}" TargetType="Tool" /> <!--</igRibbon:ToolHorizontalWrapPanel>--> </DataTemplate>IF we do that can we achieve something? it was giving me error, you can not add into QAT.
Hello,
Thank you for your post. I have been looking into it and since this is not a known issue I cannot be completely sure what can cause such behavior, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Let me explain you in diff way.
Let say I have a collection of
ObservableCollection<NavigationItem> Navitems WHERE NavigationItem is my Class with property of ID,Name,Description etc. I would like to Bind this collection to igRibbon:QuickAccessToolbar.This is my Style of the Code...
<Style TargetType="{x:Type igRibbon:QuickAccessToolbar}"> <Setter Property="ItemTemplate" Value="{StaticResource Local_DefaultQuickAccessToolbarTemplate}" /> <Setter Property="ItemsSource" Value="{Binding Navitems }"/> <!--<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" />--> </Style>AND this is my DATATEMPLATE
<DataTemplate x:Key="Local_DefaultQuickAccessToolbarTemplate" > <!--<igRibbon:ToolHorizontalWrapPanel>--> <igRibbon:QatPlaceholderTool igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge" TargetId="{Binding Name}" TargetType="Tool" /> <!--</igRibbon:ToolHorizontalWrapPanel>--> </DataTemplate>Code giving me error, when my collection is getting updated with adding one items..Item of type 'NavigationItem' cannot be added directly to the QuickAccessToolbar. Only QatPlaceholderTools and SeparatorTools can be added directly to the Qat. To add another tool type to the Qat, add a QatPlaceholderTool with a ToolId that references the actual tool you would like to add.Please help..
Hello again,
The XamRibbon's QAT can only contains QATPlaceHolderTools with set TargetID. If you want to bind the QAT ItemsSource you should use the approach the other user uses with ObservableColelction<FrameworkElement>.
I have one more question on XamRibbon.
My Xamribbon is completely bound to collection of items ObservavbleCollection<Class> . And It apper as a Button tool in RibbonGroup.
When I right I get the "Add to Quick Access ToolBar", but when click on the item i get the error "Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead" How Can i fix it.
As I want to have that Item to be added into the quick access toolbar. Please give us some idea. I am using MVVM in my application.
Any update on my question?
Could you please tell me if you use the suggested approach for using ObservableCollection<FrameworkElement>. If yes, could you please send me an isolated sample project, where your issue is reproduced, so I can investigate it further for you?