PopupContent doesn't show when SharedResourceKeys.WindowTitleBarButtonBaseStyleKey style is used

WPF Studio, Themes, and Shared Library for WPF Forum

The latest build of this product (v25.1.1) was released 3 months ago, which was before this thread was created.
Posted 17 days ago by bcs99
Version: 25.1.1
Avatar

I want to use the WindowTitleBarButtonBaseStyleKey style with a popupbutton in the TitleBarRightContent area of a WindowChrome.  It works fine if it uses the PopupMenu property, but not when the PopupContent property is used.  If I remove the style, it works, but the styling is also not applied so it doesn't fit with the rest of the PopupButtons that do use a PopupMenu.

<shared:PopupButton DisplayMode="ButtonOnly" 
                    Style="{DynamicResource {x:Static themes:SharedResourceKeys.WindowTitleBarButtonBaseStyleKey}}">
    <shared:DynamicImage Source="pack://application:,,,/Icons/Arrange16.png" />  
    <shared:PopupButton.PopupContent>
            <TextBlock>This is some content</TextBlock>
    </shared:PopupButton.PopupContent>
</shared:PopupButton>

What appears to be happening is that the PopupButton is selected (you can see the color change) but nothing else changes (no popup content).  Click away from the button and the color returns to unselected.  So, it is trying to change but not fully. 

What am I missing?

Bob

Comments (2)

Posted 16 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bob,

The WindowTitleBarButtonBaseStyleKey targets ButtonBase and doesn't have the required pieces in its Template that a PopupButton needs to show a popup, which include a special named part along with a Popup.  The reason the PopupButton.PopupMenu works is that in that case, it's just watching for a regular control click and it shows the related ContextMenu in response.  No Popup is required for that scenario.

Unfortunately we don't have a built-in Style for a PopupButton in a Window title bar.  If you have a WPF Studio license, you can download our default styles and templates.  You could make a custom Style that is based on WindowTitleBarButtonNormalTemplate, but merges in some template pieces of PopupButtonDefaultTemplate like something named PART_IndicatorArea (that is the clickable area of the button) and a PART_Popup.  If you do that, you should be able to get popup content working with a similar appearance to other title bar buttons.


Actipro Software Support

Posted 16 days ago by bcs99
Avatar

Ok. Thanks for the response.  Sometimes you just need to know what you can or cannot do. 

Add Comment

Please log in to a validated account to post comments.