How to bind ribbon gallery mediaImaging:BitmapImage?

Ribbon for WPF Forum

Posted 8 years ago by Aimee
Version: 11.1.0543
Avatar
Hi,

I have a simple gallery in my ribbon, much like the one in your sample application:

<ribbon:RibbonGallery Name="gallery" MediumVariantColumnCount="4" ImageSourceLarge="/Images/Ribbon/Actions32.png" IsSelectionHighlightVisible="True" Label="Form Layout" ScreenTipDescription="Manage Items">
  <ribbon:RibbonGallery.ItemsSource>
    <x:Array Type="{x:Type mediaImaging:BitmapImage}">
      <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="Add New Item" x:Name="Add" UriSource="/Images/Ribbon/Add.png"/>
       <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="Delete Item" x:Name="Delete" UriSource="/Images/Ribbon/Delete.png"/>
    </x:Array>
  </ribbon:RibbonGallery.ItemsSource>
  <ribbon:RibbonGallery.ItemTemplate>
    <DataTemplate>
      <Image Margin="2" Source="{Binding BindsDirectlyToSource=True}" Stretch="None"/>
    </DataTemplate>
  </ribbon:RibbonGallery.ItemTemplate>
  <ribbon:RibbonGallery.PopupContent>
    <StackPanel>
      <ribbon:PopupGallery InitialColumnCount="4" IsSelectionHighlightVisible="True" 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>
Since I am using mediaImaging:BitmapImage for this gallery how do I bind it to do something? It doesn't function like a normal ribbon button and have a command option. I have looked at your sample application, but none of your mediaImaging:BitmapImage gallery items actually bind and do something.

Please give advice how to bind.

Many thanks

[Modified at 11/22/2011 04:01 AM]

Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You could make your own custom data object that has a BitmapImage property and a Command property on it. Then use that object type as your items source instead of BitmapImage directly, and bind to the properties of your custom object.

I should also mention that you may need to override ItemContainerStyle with a Style for GalleryItem that sets its Command property to a command binding as well.

[Modified at 11/22/2011 07:32 AM]


Actipro Software Support

The latest build of this product (v2019.1 build 0684) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.