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.
I would like to understand your solution. Can you please post more about your solution.
I am trying to use also Binding as posted by you, but I was not able to make is work.
This is how my XAML looks like:
<igRibbon:XamRibbon.QuickAccessToolbar >
<igRibbon:QuickAccessToolbar ItemsSource="{Binding Path=QatItems}"
</igRibbon:QuickAccessToolbar>
</igRibbon:XamRibbon.QuickAccessToolbar>
This is how my property in my viewmodel looks like
public ObservableCollection<FrameworkElement> QatItems
{
get
return qatItems;
}
set
qatItems = value;
This os the error i get.
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
Thanks