Posted 13 years ago
by Vincent van Rooijen
I use a RibbonGallery with databinding.
The binding works well when an item is clicked, however the command won't execute when the RibbonGallery popup is opened (to show the entire list)
The binding works well when an item is clicked, however the command won't execute when the RibbonGallery popup is opened (to show the entire list)
<ribbon:RibbonGallery
ItemsSource="{Binding Source={StaticResource chartPresetValues}}"
Command="{Binding ChartCommands.ApplyPreset}"
LargeVariantColumnCount="4"
MediumVariantColumnCount="3"
IsSelectionHighlightVisible="False"
Label="{x:Static localResources:RibbonChartResources.PopupButtonChartTypeCaption}"
ImageSourceLarge=""
VariantBehavior="NoAutoSize">
<ribbon:RibbonGallery.ItemContainerStyle>
<Style
TargetType="{x:Type ribbon:GalleryItem}">
<Setter
Property="Padding"
Value="0" />
</Style>
</ribbon:RibbonGallery.ItemContainerStyle>
<ribbon:RibbonGallery.ItemTemplate>
<DataTemplate>
<Image
Source="{Binding BindsDirectlyToSource=True, Converter={StaticResource chartPresetToImageConverter}}"
ribbon:ScreenTipService.ScreenTipHeader="{Binding Converter={StaticResource chartPresetToStringConverter}}"
ribbon:ScreenTipService.ScreenTipDescription="{Binding Converter={StaticResource chartPresetToStringConverter}, ConverterParameter=x}"
Stretch="None"
Margin="3"
SnapsToDevicePixels="True" />
</DataTemplate>
</ribbon:RibbonGallery.ItemTemplate>
<ribbon:RibbonGallery.PopupContent>
<StackPanel>
<ribbon:PopupGallery
InitialColumnCount="4"
IsSelectionHighlightVisible="False"
ItemTemplate="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ribbon:RibbonGallery}}, Path=ItemTemplate}"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ribbon:RibbonGallery}}, Path=ItemsSource}" />
</StackPanel>
</ribbon:RibbonGallery.PopupContent>
<ribbon:RibbonGallery.CommandParameter>
<self:ObjectValueCommandParameter />
</ribbon:RibbonGallery.CommandParameter>
</ribbon:RibbonGallery>