PopupGallery messing up RibbonGallery DataTemplate

Ribbon for WPF Forum

Posted 14 years ago by Ken Hanson
Version: 10.1.0522
Platform: .NET 3.5
Environment: Windows 7 (64-bit)
Avatar
I have a RibbonGallery that shows a Catagorized Popup Gallery. The DataTemplate I am using shows a icon that happens to be Xaml. For this reason I use a ContentPresenter in my DataTemplate.

I see the Xaml Icons (with labels) in the RibbonGallery.
I pop open the PopupGallery and it still looks good and I see the Xaml Icons (with labels)

The Bug
However, when I close the PopupGallery, my initial RibbonGallery no longer shows the Xaml Icons, it only shows the labels in my Data Template. The PopupGallery still works correctly and shows it's ContentPresenter icons.

Below is the RibbonGallery in my main.xaml.

Any suggestions?

Best Regards,

Ken


<ribbon:RibbonGallery  ItemsSource="{Binding Source={StaticResource ControlsDataSrc}, Path=Controls}"   MediumVariantColumnCount="5" LargeVariantColumnCount="3" ImageSourceSmall="/Resources/Images/ColorPicker32.png">
                            <ribbon:RibbonGallery.ItemTemplate>
                                <DataTemplate >
                                    <Grid Width="72" Height="22">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                        </Grid.RowDefinitions>
                                        <ContentPresenter  Content="{Binding BindsDirectlyToSource=True, Path=WrappedObject.Image}" Grid.Row="0"/>
                                        <TextBlock Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="9" Text="{Binding BindsDirectlyToSource=True, Path=WrappedObject.ItemString}" />
                                    </Grid>
                                </DataTemplate>
                            </ribbon:RibbonGallery.ItemTemplate>
                            <ribbon:RibbonGallery.PopupContent>
                                <StackPanel>
                                    <ribbon:PopupGallery InitialColumnCount="3"
                                            IsPreviewEnabled="True" IsSelectionHighlightVisible="False"
                                            CategorizedItemsSource="{Binding Source={StaticResource ControlsDataSrc}, Path=Controls}"
                                                         >
                                        <ribbon:PopupGallery.ItemTemplate>
                                            <DataTemplate >
                                                <Grid Width="60" Height="44">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="*" />
                                                        <RowDefinition Height="Auto" />
                                                    </Grid.RowDefinitions>
                                                    <ContentPresenter Content="{Binding BindsDirectlyToSource=True, Path=WrappedObject.Image}" />
                                                    <TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="9" Text="{Binding BindsDirectlyToSource=True, Path=WrappedObject.ItemString}" />
                                                </Grid>
                                            </DataTemplate>
                                        </ribbon:PopupGallery.ItemTemplate>
                                    </ribbon:PopupGallery>
                                </StackPanel>
                            </ribbon:RibbonGallery.PopupContent>

                        </ribbon:RibbonGallery>

Comments (2)

Posted 14 years ago by Ken Hanson
Avatar
Never mind. Solution Found.

This is really just a issue with WPF that I forgot. The FrameworkElement I am using as my icon cannot have two parents. So when the GalleryPopup opens it becomes the parent and the GalleryRibbon looses those icons. I need to either deep clone the icons or else make bitmaps of them.

Thanks,

Ken
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ken,

Yes, if that is happening then that must mean your icons are being used as WPF visuals and visuals can only exist in one hierarchy at a time. When you open PopupButton, since they share the same ItemsSource it is pulling them out of RibbonGallery and into PopupGallery. This is not due to our control implementation, it would happen if you used any two ItemsControls in the same way.

Instead what you could do is find a way to use DrawingImage instead. That takes a Drawing, which can consist of shapes, and is reusable because it can be assigned as an Image's Source.


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.