RibbonGallery command not triggered on popup window

Ribbon for WPF Forum

Posted 13 years ago by Vincent van Rooijen
Avatar
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)
<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>

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Vincent,

Please try setting the Command on the PopupGallery as well. I don't believe that just setting it on the RibbonGallery will bubble it down to PopupGallery since it's a different control.


Actipro Software Support

Posted 13 years ago by Vincent van Rooijen
Avatar
I added the command to the PopupGallery without any luck, your examples of the ribbon neither do have this functionality, how do I achieve this anyway?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Vincent,

The Gallery Rows QuickStart shows how the Command property can be used in the RibbonGallery and PopupGallery. Just to be clear, the command is not raised when the popup is opened, it raised for the items only.

If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Vincent,

Thanks for the sample, we were able to track down and fix the issue. The problem was the DataContext is not being properly inherited down from the RibbonGallery to the PopupGallery. This fix will be in the next maintenance release.

As a work around, you could give the RibbonGallery a name (i.e. x:Name="gallery") and add this to your PopupGallery DataContext="{Binding ElementName=gallery, Path=DataContext}".


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.