Gallery Column count not working

Ribbon for WPF Forum

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

I have a simple bitmap image gallery consisting of 4 images. I would like to have 4 columns set as default, resulting in all 4 images being displayed by default. Then other images/options may be added to this gallery in the future, but for now it is just 4 images.

<ribbon:RibbonGallery Name="gallery" LargeVariantColumnCount="12" 
MediumVariantColumnCount="6" VariantSize="Large" 
VariantBehavior="NoAutoSize" ImageSourceLarge="/Images/Ribbon/FormLayout32.png" IsSelectionHighlightVisible="False" Label="Form Layout">
      <ribbon:RibbonGallery.ItemsSource>
            <x:Array Type="{x:Type mediaImaging:BitmapImage}">
                <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="Two column layout" x:Name="Gallery2Column" UriSource="/Images/Ribbon/Layout/GalleryLayout2Column.png"/>
                <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="Two column layout with labels stacked above the input fields" x:Name="Gallery2ColumnStacked" UriSource="/Images/Ribbon/Layout/GalleryLayout2ColumnStacked.png"/>
                <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="4 column layout" x:Name="Gallery4Column" UriSource="/Images/Ribbon/Layout/GalleryLayout4Column.png"/>
                <mediaImaging:BitmapImage ribbon:ScreenTipService.ScreenTipHeader="1 column layout with labels stacked above the input fields" x:Name="Gallery1ColumnStacked" UriSource="/Images/Ribbon/Layout/GalleryLayout1ColumnStacked.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="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>
I have set the variant size to large, and set both the medium and large column counts to above 4 but this just doesn't work. It still displays the default 3 columns. I have changed the variant behavior to all 4 options (default, noautosize etc), but it still doesn't work.

This gallery is the only item in this group and tab, so it has plenty of space to grow.

Am I doing something obviously wrong?

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aimee,

Why don't you take out these RibbonGallery attributes completely:
LargeVariantColumnCount="12"
MediumVariantColumnCount="6"
VariantSize="Large"

You could optionally put this in their place:
MediumVariantColumnCount="4"


Actipro Software Support

Posted 12 years ago by Aimee
Avatar
Hi,

That didnt work. But what I didn't mention before was that this gallery was in a usercontrol. So in my ribbon I had:

<ribbon:Tab Label="Page Design">
      <ribbon:Group Label="Form Layout" ImageSourceLarge="/Images/Ribbon/FormLayout32.png">
         <myRibbon:FormLayout />
      </ribbon:Group>
</ribbon:Tab>
And then the above code inside of a usercontrol. I have now moved it out of the usercontrol into the ribbon and it now works.

There is no reason for it to be in a usercontrol other than trying to be tidy and extract potentially large pieces of code into their own space. So I am happy for it to remain in the ribbon, though for future reference, if I did require a gallery in a usercontrol, any ideas why this would prevent the column count from working?

Cheers
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aimee,

A number of ribbon controls require being directly parented to the containing Group or other ribbon controls to work properly. RibbonGallery is one of those.

You could move the RibbonGallery over to its own class and have it as the root, instead of a UserControl, if you do want to separate things out.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.