ColorPickerGallery SelectedItem

Ribbon for WPF Forum

Posted 14 years ago by James Crain
Version: 9.1.0500
Avatar
It appears as though trying to access the SelectedItem of a ColorPickerGallery, when it is inside a PopupButton, does not work.

Please see my code below, but I am simply trying to use the ColorPickerGallery inside of the PopupContent of a PopupButton. Currently, I have the SelectedItem bound to the Background of a Button inside of the PopupContent (code I got off of the forum here).

However, I have also tried this using a Command, and also by creating a "SelectedItem" property that inherits from INotify.

None of these seem to trigger the newly SelectedItem.

Any suggestions?

Thanks,

James

Code:

<shared:PopupButton x:Name="_myPopupButton"
                    Content="Test Me"
                    Width="75"
                    DisplayMode="Merged">
         <shared:PopupButton.PopupContent>
            <Border Width="176"
                    Background="White"
                    BorderBrush="Gray"
                    BorderThickness="1">
               <StackPanel>
                  <ribbon:ColorPickerGallery InitialColumnCount="10"
                                             HorizontalAlignment="Center"
                                             SelectedItem="{Binding ElementName=TargetButton, Path=Background, Mode=TwoWay}">
                     <ribbon:ColorPickerGallery.CategorizedItemsSource>
                        <x:Array Type="{x:Type media:SolidColorBrush}">
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#FFFFFF" ribbon:ScreenTipService.ScreenTipHeader="White" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#000000" ribbon:ScreenTipService.ScreenTipHeader="Black" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#EEECE1" ribbon:ScreenTipService.ScreenTipHeader="Tan" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#1F497D" ribbon:ScreenTipService.ScreenTipHeader="Dark Blue" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#4F81BD" ribbon:ScreenTipService.ScreenTipHeader="Blue" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#C0504D" ribbon:ScreenTipService.ScreenTipHeader="Red" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#9BBB59" ribbon:ScreenTipService.ScreenTipHeader="Olive Green" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#8064A2" ribbon:ScreenTipService.ScreenTipHeader="Purple" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#4BACC6" ribbon:ScreenTipService.ScreenTipHeader="Aqua" />
                           <media:SolidColorBrush ribbon:PopupGallery.Category="Theme Colors" ribbon:ColorPickerGallery.LayoutBehavior="Shaded" Color="#F79646" ribbon:ScreenTipService.ScreenTipHeader="Orange" />
                        </x:Array>
                     </ribbon:ColorPickerGallery.CategorizedItemsSource>
                  </ribbon:ColorPickerGallery>
                  <Button x:Name="TargetButton" Background="Red">Target Button</Button>
               </StackPanel>
            </Border>
         </shared:PopupButton.PopupContent>
      </shared:PopupButton>

Comments (2)

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

This was actually a bug with the shared:PopupButton. It was not adding the PopupContent as a logical child, and as such the element name look-up was not working correctly. I've corrected this for the next maintenance release.

In the meantime, you could wrap your controls in an DataTemplate and set PopupContentTemplate instead.


Actipro Software Support

Posted 14 years ago by James Crain
Avatar
Thank you so much for the quick reply. I was actually able to use the SelectionChangedEvent as a work around, but I will certainly try the one you have suggested as well.

James
The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.